By implementing InitializingBean and DisposableBean interfaces
Providing init-method and destroy-method in xml configuration or @PostConstruct and @PreDestroy annotations for methods
1 |
@Bean(initMethodName="init") |
1 |
<bean id="service" class="Service" init-method="init" destroy-method="destroy"> |
For activating post processor annotation annotations use
1 |
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" /> |
or by
1 |
<context:annotation-config> |
used to activate applied annotations in already registered beans in application context (context:component-scan does what context:annotation-config does, but additionally it scan the packages and register the beans)
ApplicationContextAware –
BeanFactoryAware –
BeanNameAware –
ResourceLoaderAware –
ServletContextAware –
ServletConfigAware –