com.ibm.portal.app.component
Interface Templatable


public interface Templatable

Templatable is one of the Application Component Interfaces, implemented by a composite application component. Templatable is used to save your component's state information in an application template and to recreate it from a template.

Lifecycle.removeInstance(String) will be called to compensate for a failed template instantiation.

Note: The component instance identifier input parameter used in Templatable methods is the identifer returned by the createFromTemplate(Reader, ListModel) method if it was created from a template, otherwise it is the id from the Lifecycle.createInstance(ListModel) method.

Since:
6.0

Method Summary
 ListModel java.io.Reader, com.ibm.portal.ListModel)">createFromTemplate(java.io.Reader objectData, ListModel variables)
          Called when an instance of this component is created from a template.
 ListModel java.io.Writer)">serializeToTemplate(java.lang.String id, java.io.Writer objectData)
          Writes a description of this component instance to a Writer.
 

Method Detail
java.io.Writer)">

serializeToTemplate

ListModel serializeToTemplate(java.lang.String id,
                              java.io.Writer objectData)
                              throws java.io.IOException,
                                     ComponentException
Writes a description of this component instance to a Writer. That description will be saved in an application template. Called when a template containing this component is saved. The character stream represents the state of an application component instance. The characters are saved in the template, which is an XML file. Therefore the character must be valid within an XML file. You can store whatever information you need in this XML. When a new application is created from the template, the saved characters are passed to your component's createFromTemplate(Reader, ListModel) method, when a new application is created from the template.

Parameters:
id - component instance identifier, must not be null.
objectData - A sink for the state describing this component instance stored in characters that must be valid within an XML file: <object-data>your characters</object-data>
Returns:
ListModel containing Variable objects for parameter variables. This list contains the variables that should be visible in the scope of the template. This is not necessarily the complete list of all variables supported by this component. The list must not be null but may be empty.
Throws:
java.io.IOException - If an I/O error occurs when writing to the objectData java.io.Writer.
ComponentException - if you throw an exception during this method call the serialization of the whole application into a template will fail.

java.io.Reader, com.ibm.portal.ListModel)">

createFromTemplate

ListModel createFromTemplate(java.io.Reader objectData,
                             ListModel variables)
                             throws java.io.IOException,
                                    ComponentException
Called when an instance of this component is created from a template. The passed in objectData parameter will contain the same data that was created by your component's serializeToTemplate(String) method and got saved in the template.

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:
objectData - the state of your component provided during serializeToTemplate(String). If not state was provided the Reader provides 0 characters, must not be null.
variables - the list of resolved parameters of your component as Variable objects 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.
Throws:
java.io.IOException - If an I/O error occurs when reading the objectData from the java.io.Reader
ComponentException - if you throw an exception during this method call the creation of the whole creation of the application from the template will fail.