• 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

Skills421

Welcome to Skills421, our knowledge repository for all things tech in the 21st century

Let’s connect

Search