Spring Bean Life Cycle Tutorial
The life cycle of beans consist of call back methods which can be categorized broadly in two groups:
Spring framework provides following 4 ways for controlling life cycle events of bean:
package com.jtc;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
public class DemoBeanTypeOne implements InitializingBean, DisposableBean
{
//Other bean attributes and methods
@Override
public void afterPropertiesSet() throws Exception
{
//Bean initialization code
}
@Override
public void destroy() throws Exception
{
//Bean destruction code
}
}