Professional Documents
Culture Documents
19 Bean Lifecycle Methods Overview
19 Bean Lifecycle Methods Overview
Bean Lifecycle
Container Is Shutdown
Your Custom
Destroy Method
www.luv2code.com
Bean Lifecycle Methods / Hooks
• You can add custom code during bean initialization
www.luv2code.com
Init: method configuration
<beans … >
<bean id="myCoach"
class="com.luv2code.springdemo.TrackCoach"
init-method="doMyStartupStuff">
…
</bean>
</beans>
www.luv2code.com
Destroy: method configuration
<beans … >
<bean id="myCoach"
class="com.luv2code.springdemo.TrackCoach"
init-method="doMyStartupStuff"
destroy-method="doMyCleanupStuff">
…
</bean>
</beans>
www.luv2code.com
Development Process
Step-
By-S
tep
1. Define your methods for init and destroy
www.luv2code.com