Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » beans » factory » annotation » [javadoc | source]
org.springframework.beans.factory.annotation
public class: InitDestroyAnnotationBeanPostProcessor [javadoc | source]
java.lang.Object
   org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor

All Implemented Interfaces:
    PriorityOrdered, DestructionAwareBeanPostProcessor, Serializable, MergedBeanDefinitionPostProcessor

Direct Known Subclasses:
    CommonAnnotationBeanPostProcessor

org.springframework.beans.factory.config.BeanPostProcessor implementation that invokes annotated init and destroy methods. Allows for an annotation alternative to Spring's org.springframework.beans.factory.InitializingBean and org.springframework.beans.factory.DisposableBean callback interfaces.

The actual annotation types that this post-processor checks for can be configured through the "initAnnotationType" and "destroyAnnotationType" properties. Any custom annotation can be used, since there are no required annotation attributes.

Init and destroy annotations may be applied to methods of any visibility: public, package-protected, protected, or private. Multiple such methods may be annotated, but it is recommended to only annotate one single init method and destroy method, respectively.

Spring's org.springframework.context.annotation.CommonAnnotationBeanPostProcessor supports the JSR-250 javax.annotation.PostConstruct and javax.annotation.PreDestroy annotations out of the box, as init annotation and destroy annotation, respectively. Furthermore, it also supports the javax.annotation.Resource annotation for annotation-driven injection of named beans.

Field Summary
protected final  Log logger    Logger available to subclasses 
Method from org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor Summary:
getOrder,   postProcessAfterInitialization,   postProcessBeforeDestruction,   postProcessBeforeInitialization,   postProcessMergedBeanDefinition,   setDestroyAnnotationType,   setInitAnnotationType,   setOrder
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor Detail:
 public int getOrder() 
 public Object postProcessAfterInitialization(Object bean,
    String beanName) throws BeansException 
 public  void postProcessBeforeDestruction(Object bean,
    String beanName) throws BeansException 
 public Object postProcessBeforeInitialization(Object bean,
    String beanName) throws BeansException 
 public  void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition,
    Class beanType,
    String beanName) 
 public  void setDestroyAnnotationType(Class destroyAnnotationType) 
    Specify the destroy annotation to check for, indicating destruction methods to call when the context is shutting down.

    Any custom annotation can be used, since there are no required annotation attributes. There is no default, although a typical choice is the JSR-250 javax.annotation.PreDestroy annotation.

 public  void setInitAnnotationType(Class initAnnotationType) 
    Specify the init annotation to check for, indicating initialization methods to call after configuration of a bean.

    Any custom annotation can be used, since there are no required annotation attributes. There is no default, although a typical choice is the JSR-250 javax.annotation.PostConstruct annotation.

 public  void setOrder(int order)