Schematic
https://www.processon.com/apps/5d1c16dde4b076f4fd3f5c40
package com.beanPostProcessor; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.core.PriorityOrdered; import org.springframework.stereotype.Component; @Component public class Lwj_BeanPostPocessor implements BeanPostProcessor, PriorityOrdered { // achieve PriorityOrdered, to achieve a smaller value getOrder method returns the execution front @Override public int getOrder() { return 102; } // initialization section before implantation method @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if("wjwTest".equals(beanName)){ System.out.println ( "previous methods Lwj_BeanPostPocessor"); } return bean; } // Initialize section after implantation method @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if("wjwTest".equals(beanName)){ System.out.println ( "method after Lwj_BeanPostPocessor"); } return bean; } }
This is one way to provide the extension point spring, spring in the presence of a total of five kinds of expansion mode.
Then call prototype (the prototype) application singleton (Singleton) can be used in two ways
Lookup way to note that @Lookup can only comment on the method, this time to comment on an abstract method.
Implement ApplicationContextAware interface set method, this method is to recreate a beanFactory then get a bean from the factory again and this time the newBean original factory in oldBean the same type but not in the same heap in LVM