Object life cycles and the Blueprint Container

In the Blueprint programming model, a bean manager can manage the life cycle of the object that it creates. The bean manager can notify an object after all properties are injected, or when an object instance is destroyed.

The Blueprint Container specification defines the following callback methods:
init-method
Specifies a method to be call after all properties are injected into an object. The method must be public, does not take any arguments, and does not return any value.
destroy-method
Specifies a method to call when the Blueprint Container destroys the object instance. The method must be public, does not take any arguments, and does not return any value.

The destroy-method callback is not supported for beans with a scope of prototype. In this situation, the application is responsible for destroying those instances.

The following code examples show an example of a Java™ class with lifecycle methods and a Blueprint XML bean entry that specifies the init-method and destroy-method attributes.

public class Account {      
   public Account(long number) {
      ...
   }
   public void init() {
      ...
   }
   public void destroy() {
      ...
   }
}
<bean id=”accountFour” class=“org.apache.aries.simple.Account” 
   init-method=”init” destroy-method=”destroy”>
   <argument value=”6”/>
   <property name=”description” value=”#6 account”/>
</bean>