Tuesday, March 1, 2011

Spring – InitializingBean and DisposableBean


Spring – InitializingBean and DisposableBean 

In Spring, InitializingBean and DisposableBean are two interfaces, implementing these interfaces will make Spring calling afterPropertiesSet() for the former and destroy() for the latter to allow the bean to perform certain actions upon initialization and destruction.
Here’s an example to show how to use InitializingBean and DisposableBean.
in Spring, it’s encouraged to use init-method=”method name” and destroy-method=”method name” as attribute in bean configuration file for bean to perform certain actions upon initialization and destruction.

1 comment: