(Source Code) Default initialization & destroy methods in Spring Framework
Source Code : Default initialization & destroy methods in Spring Framework
Spring container has features that it can auto detect your initialization and Destroy method if you follow same coding convention in project.
Code:
<beans default-init-method="init"> <bean id="sampleService" class="org.abc.DefaultSample"> <property name="samplename" ref="sampleName" /> </bean> </beans>
Destroy method callbacks are also similarly use the 'default-destroy-method'
Attribute on the top-level <beans/> element. So Spring IoC container will recognize a method called 'init' on beans as being the initialization method callback, and when a bean is being created and assembled, if the bean's class has such a method, it will be invoked at the appropriate time.
Courtesy:- Java-forums.org
- guru's blog
- Login to post comments
