Class InitDestroyAnnotationBeanPostProcessor

java.lang.Object
org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor
All Implemented Interfaces:
Serializable, BeanRegistrationAotProcessor, BeanPostProcessor, DestructionAwareBeanPostProcessor, MergedBeanDefinitionPostProcessor, Ordered, PriorityOrdered
Direct Known Subclasses:
CommonAnnotationBeanPostProcessor

BeanPostProcessor implementation that invokes annotated init and destroy methods. Allows for an annotation alternative to Spring's InitializingBean and 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 CommonAnnotationBeanPostProcessor supports the PostConstruct and PreDestroy annotations out of the box, as init annotation and destroy annotation, respectively. Furthermore, it also supports the Resource annotation for annotation-driven injection of named beans.

Since:
2.5
Author:
Juergen Hoeller, Stephane Nicoll, Phillip Webb, Sam Brannen
See Also: