Runtime components : Core components : ElementFactory : Tasks : Customizing Element
  
Customizing Element
If you want to keep the instance of ElementFactory in the created Element, you need to create your Element implementing the interface com.ibm.btt.element.FactoryAwareElement. ElementFactory will call setElementFactory method.
public void setElementFactory(ElementFactory elementFactory) throws ElementException;
ElementFactory can manage the life cycle of element by calling the lifecycle method, such as initialize(), init(), destroy(), dispose(), and so on. There is no argument in the method.
Take the following element for example:
public class MyElement {
  public void initialize() {
    // some logic here
  }
  public void destroy() {
    // some logic here
  }
}
If you want ElementFactory to call the initialize() method of MyElement when the element is well populated, and call the destroy() method when the ElementFactory is about to be destroyed, you need to define the element in the following style:
<myPackage.MyElement id="myElement" InitMethod="initialize" DestroyMethod="destroy"/>
The attribute InitMethod is used to identify the initializing method, and the attribute DestroyMethod is used to specify the destroy method. Destroymethod is only applicable to singleton element. If you define this attribute for a prototype element, ElementFactory will ignore it.
In your application project, you can make a naming convention for the lifecycle method. For example, you can declare all the initialize method as “initialize”, and all the destroy method as “destroy”. It is helpful when defining the default lifecycle method name.
Following is an example of how to define the default lifecycle method name:
<com.ibm.btt.element.impl.LifeCycleProcessorImpl
id="lifeCycleProcessor" defaultInitMethod="initialize"
defaultDestroyMethod="destroy" />
lifeCycleProcessor is the ID. com.ibm.btt.element.impl.LifeCycleProcessorImpl is a class which has two fields: defaultInitMethod and defaultDestroyMethod.
You can also implement your own LifeCycleProcessor, which must implement the interface com.ibm.btt.element.LifeCycleProcessor.
Go up to
Tasks