+

Search Tips   |   Advanced Search

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>


Related:

  • Blueprint bundles
  • Blueprint XML
  • Beans and the Blueprint Container
  • Services and the Blueprint Container
  • References and the Blueprint Container
  • Scopes and the Blueprint Container
  • Object values and the Blueprint Container
  • Resource references and the Blueprint Container
  • Dynamism and the Blueprint Container
  • Type converters and the Blueprint Container
  • JNDI lookup for blueprint components
  • Developing an OSGi application
  • OSGi Service Platform Release 4 Version 4.2 Enterprise Specification
  • Building OSGi applications with the Blueprint Container specification




    File name: was313.html

    prettyPrint();