Spring Framework

Spring Projects

Spring Project 1

adplus-dvertising
Lifecycle management of IOC container
Previous Home Next

Introduction: The IOC container provide the facility of notifying beans about the creation and destruction show that bean can perform initialization or cleanup perforation. It means that the IOC container provide the facility to notifying create of bean and destroy of bean. Initialization and destruction of a bean is notified to it.

The IOC container notifying the creation and destruction either of the following two ways:

  1. Non-Intrusive approach
  2. Intrusive approach

Non-Intrusive approach: A non-intrusive approach an initialization method is defined in the bean and is specified in the bean configuration using init-method attribute.

Syntax:

< <bean id="one" class="org.r4r.One" init-method="init"/>

Intrusive approach: In the intrusive approach initialization bean interface provided by the framework is implemented in the bean class and initializing logic is contain with it after property set method. This method is provided by "InitializingBean" interface.

InitializingBean

The InitializingBean interface provide cleanup operation at the time of unloading of a bean either destroy-method attribute of bean is used.

This interface provide a method name which are following:

public void afterPropertiesSet();

Syntax:

 <bean id="one" class="org.r4r.One" destroy-method="init"/>

DisposableBean

This bean interface is provided by framework is implemented. This interface provide a method name destroy() if is invoked by IOC container before unload by IOC container before unloaded bean.

This interface provide single method name destroy().

public void destroy();

Previous Home Next