- Initialization Callbacks
- Destruction Callbacks
Initialization Callbacks
public class Example1 implements InitializingBean
{
public void afterPropertiesSet()
{
}
}
<bean id="exampleBean" class="Example2" init-method="init"/>
public class Example2
{
public void init()
{
}
}
Destruction Callbacks
public class Example1 implements DisposableBean
{
public void destroy()
{
}
}
<bean id=”exampleBean” destroy-method=”destroy”/>
public class Example2
{
public void destroy()
{
}
}
AbstractApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
context.registerShutdownHook();
Hello obj = (Hello) context.getBean("helloWorld");
System.out.println(obj.getMessage());


Leave a comment