Wednesday, 20 April 2016

How to use bean lifecycle methods ?


There are two important bean lifecycle methods.
setup (init-method) : called when the bean is loaded in to the container.
teardown (destroy) : called when the bean is unloaded from the container.

We can override beans default lifecycle methods.
The bean tag has two more important attributes with which you can define your own custom initialization and destroy methods.
<beans>
     <bean id="bar" class="com.genius.Foo"
           init-method=”fooSetup destroy=”fooTeardown” />
</beans>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.