Class GenericBeanPostProcessorAdapter<T>
- java.lang.Object
-
- io.microsphere.spring.beans.factory.config.GenericBeanPostProcessorAdapter<T>
-
- Type Parameters:
T- the type of beans this post-processor will operate on
- All Implemented Interfaces:
org.springframework.beans.factory.config.BeanPostProcessor
- Direct Known Subclasses:
InterceptingApplicationEventMulticasterProxy
public abstract class GenericBeanPostProcessorAdapter<T> extends java.lang.Object implements org.springframework.beans.factory.config.BeanPostProcessorGeneric adapter implementation of theBeanPostProcessorinterface, providing type-safe processing for beans of a specific type. This class simplifies the development of typedBeanPostProcessorimplementations by allowing subclasses to handle only the bean types they are interested in.Subclasses can override either the pre / post initialization hook methods (
processBeforeInitialization(Object, String)andprocessAfterInitialization(Object, String)) if they wish to perform processing without returning a modified bean instance, or the more advanceddoPostProcessBeforeInitialization(Object, String)anddoPostProcessAfterInitialization(Object, String)methods if they need to return a modified bean instance.Example Usage
public class MyBeanPostProcessor extends GenericBeanPostProcessorAdapter<MyBean> { protected void processBeforeInitialization(MyBean bean, String beanName) { // Custom logic before bean initialization } protected void processAfterInitialization(MyBean bean, String beanName) { // Custom logic after bean initialization } }- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
BeanPostProcessor
-
-
Constructor Summary
Constructors Constructor Description GenericBeanPostProcessorAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TdoPostProcessAfterInitialization(T bean, java.lang.String beanName)Adapter BeanPostProcessor#postProcessAfterInitialization(Object, String) method , sub-type could override this method.protected TdoPostProcessBeforeInitialization(T bean, java.lang.String beanName)Adapter BeanPostProcessor#postProcessBeforeInitialization(Object, String) method , sub-type could override this method.java.lang.Class<T>getBeanType()Bean Typejava.lang.ObjectpostProcessAfterInitialization(java.lang.Object bean, java.lang.String beanName)java.lang.ObjectpostProcessBeforeInitialization(java.lang.Object bean, java.lang.String beanName)protected voidprocessAfterInitialization(T bean, java.lang.String beanName)ProcessBeanwith name without return value after initialization,protected voidprocessBeforeInitialization(T bean, java.lang.String beanName)ProcessBeanwith name without return value before initialization,
-
-
-
Method Detail
-
postProcessBeforeInitialization
public final java.lang.Object postProcessBeforeInitialization(java.lang.Object bean, java.lang.String beanName) throws org.springframework.beans.BeansException- Specified by:
postProcessBeforeInitializationin interfaceorg.springframework.beans.factory.config.BeanPostProcessor- Throws:
org.springframework.beans.BeansException
-
postProcessAfterInitialization
public final java.lang.Object postProcessAfterInitialization(java.lang.Object bean, java.lang.String beanName) throws org.springframework.beans.BeansException- Specified by:
postProcessAfterInitializationin interfaceorg.springframework.beans.factory.config.BeanPostProcessor- Throws:
org.springframework.beans.BeansException
-
getBeanType
public final java.lang.Class<T> getBeanType()
Bean Type- Returns:
- Bean Type
-
doPostProcessBeforeInitialization
protected T doPostProcessBeforeInitialization(T bean, java.lang.String beanName) throws org.springframework.beans.BeansException
Adapter BeanPostProcessor#postProcessBeforeInitialization(Object, String) method , sub-type could override this method.- Parameters:
bean- Bean ObjectbeanName- Bean Name- Returns:
- Bean Object
- Throws:
org.springframework.beans.BeansException- See Also:
BeanPostProcessor.postProcessBeforeInitialization(Object, String)
-
doPostProcessAfterInitialization
protected T doPostProcessAfterInitialization(T bean, java.lang.String beanName) throws org.springframework.beans.BeansException
Adapter BeanPostProcessor#postProcessAfterInitialization(Object, String) method , sub-type could override this method.- Parameters:
bean- Bean ObjectbeanName- Bean Name- Returns:
- Bean Object
- Throws:
org.springframework.beans.BeansException- See Also:
BeanPostProcessor.postProcessAfterInitialization(Object, String)
-
processBeforeInitialization
protected void processBeforeInitialization(T bean, java.lang.String beanName) throws org.springframework.beans.BeansException
ProcessBeanwith name without return value before initialization,This method will be invoked by BeanPostProcessor#postProcessBeforeInitialization(Object, String)
- Parameters:
bean- Bean ObjectbeanName- Bean Name- Throws:
org.springframework.beans.BeansException- in case of errors
-
processAfterInitialization
protected void processAfterInitialization(T bean, java.lang.String beanName) throws org.springframework.beans.BeansException
ProcessBeanwith name without return value after initialization,This method will be invoked by BeanPostProcessor#postProcessAfterInitialization(Object, String)
- Parameters:
bean- Bean ObjectbeanName- Bean Name- Throws:
org.springframework.beans.BeansException- in case of errors
-
-