com.ibm.portal.app.component
Interface Lifecycle


public interface Lifecycle

Lifecycle is one of the Application Component Interfaces, implemented by an application component. Lifecycle is used to notify a component whenever an instance of that component is created or destroyed. The component can use this information to create or initialize resources needed while the component is active.

removeInstance(String) will be called to compensate for a failed application creation.

All application components are required to implement the Lifecycle interface, as well as the DisplayInfo interface.

Since:
6.0

Method Summary
 ListModel createInstance(ListModel parameters)
          Called when an instance of this component is created.
 ListModel getCreateParameters()
          Called before createInstance(ListModel) to find out what parameters (names, types) this components accepts for the instanctiation.
 void removeInstance(java.lang.String id)
          Called when an instance of this component is destroyed.
 

Method Detail

createInstance

ListModel createInstance(ListModel parameters)
                         throws ComponentException
Called when an instance of this component is created. This happens when the component is added to an existing application. For the parameters passed in to this method see getCreateParameters().

The instance identifier that you return from this method is used to identify this component instance according to the fly weight pattern. I.e. whenever the application infrastructure calls any other Application Component Interface methods this id is passed in. For example, you could store any state information for this component instance in a resource that has a unique identifer, and return that identifier as the instance ID for this component. That pattern also implies that no instance variables should be used as there is no defined relation between the Java instances of the implementation class and the component instances in the system. The instance ID can be any string, but it must distinguish this component instance from all other instances of the same component.

Parameters:
parameters - a list of Variable objects that represent the resolved parameters of your component and one variable added by the infrastructure that contains the composite application's ID (Variable.APPLICATION_ID, must not be null.
Returns:
A list of Variable objects representing export parameters. At least one Variable object with the variable name "id" is required for which the value has to be of the type Variable.STRING and is the identifier to identify this component instance, unique for all instances of this component type. This value, must not be null. In portal 6.0.x only the id is used but there is already a list returned for future extension.
Throws:
ComponentException - if you throw an exception during this method call the application will not be instantiated.

getCreateParameters

ListModel getCreateParameters()
Called before createInstance(ListModel) to find out what parameters (names, types) this components accepts for the instanctiation. The values could for example come from a portlet's preferences that is the view for this business component. Then only the preferences with the correct names and type are passed in to the createInstance(ListModel) method.

Returns:
a list of Variable objects that define valid parameter names and types to be passed in during createInstance(ListModel). The value of the Variable objects in the list define a default value for the parameter. If no default value should be defined set the string value to null. If your component does not support creation time parameters, null can be returned.

removeInstance

void removeInstance(java.lang.String id)
                    throws ComponentException
Called when an instance of this component is destroyed. This happens when the component is removed from an existing template or application, or when a template or application containing the component is destroyed.

Parameters:
id - component instance identifier returned by createInstance
Throws:
ComponentException - if you throw an exception during this method call the application will not be removed.