com.ibm.di.fc
Class AssemblyLineFC

java.lang.Object
  extended by com.ibm.di.fc.Function
      extended by com.ibm.di.fc.AssemblyLineFC
All Implemented Interfaces:
FunctionInterface, VersionInfoInterface

public class AssemblyLineFC
extends Function

This is a function component that calls an AssemblyLine(AL) on a local or remote server. The call can be made in three different modes.

  1. Run and wait for result. Each call to perform() starts the target AL and returns the result object for the execution, typically the last work Entry. initialize() does not start the target AL.
  2. Run in background. The target AL runs on its own, in the background. initialize() does not start the target AL.
  3. Manual (cycle mode). The target AL is controlled by the FC by executing a cycle for each call to perform(). initialize() starts the target AL.
When the FC runs an AssemblyLine in background mode, the FC keeps a reference to the target AL and the FC can return the status of the running/terminated assemblyline. You obtain this status simply by calling the FC with a null or empty Entry parameter. The returned Entry object contains the reference to the target AL in its "value" attribute. If you pass a null value to the FC, the return value is the actual reference to the target AL. This complies with the calling conventions of Function components in general (e.g. return an Entry object if called with Entry object).

When the FC runs an AssemblyLine in background mode, you can also call the FC with specific string values to obtain various info about the target AL:

          fc.perform("target");  // returns the object reference of the target al
          fc.perform("active");  // returns either ""active", "aborted" or "terminated" depending on the target al status
          fc.perform("error");   // returns the java.lang.Exception object when the status is "aborted"
          fc.perform("result");  // returns the current result Entry object
          fc.perform("stop");    // tries to terminate an active target al - may throw an error if call does not succeed
When the FC is called in this mode with an Entry object, the Entry object can contain one or more of the above keywords in the command Attribute. The returned Entry object is then populated with the same values as described above. So, rather than calling perform() with all keywords, you can create an Entry with all keywords as attributes in the Entry object and get away with one call to perform(): var e = system.newEntry(); e.setAttribute("command", "target, status"); var result = fc.perform(e); task.logmsg("The status is: " + result.getString("status")); When the FC runs an AL in manual mode, each call with an Entry object causes one cycle to be executed in the target AL. The returned Entry object is the work entry result of the cycle. When the target AL has completed, a null entry is returned. If the cycle execution causes an error, that error is re-thrown by the FC (you should use a try/catch block in your script).

To provide a TaskCallBlock (TCB) you can use the fc.getTCB() and set parameters in the returned TCB object. This object will be used the next time an AssemblyLine is started by this FC. You should only set connector parameters in the returned TCB as this FC will potentially overwrite the runmode and initial work entry.

Another way to set TCB parameters are by using the output attribute map where you define variables with the specific prefix "$tcb.". When these attributes are found in the entry they will be moved to the TCB and removed from the entry. This will only work when the FC runs an assemblyline each time the FC is called (e.g. run and await completion).


Field Summary
static String ASSEMBLYLINE
           
static String CONFIG
           
static String CUSTOM_SEC
           
static String CYCLE_MODE
           
static String OPERATION
           
static String OPERATION_INIT_PREFIX
           
static String SERVER
           
static String SHARE_LOG
           
static String TCB
           
static String USE_TCB_ATTRS
           
 
Fields inherited from class com.ibm.di.fc.Function
logger
 
Constructor Summary
AssemblyLineFC()
           
 
Method Summary
 Session connectServer(String server)
          Establish a server connection.
 ConfigInstance getConfigInstance(String ci)
           
 Session getSession()
           
 TaskCallBlock getTCB()
          Returns the TaskCallBlock to use before starting an instance.
 String getVersion()
          Return version information
 void initialize(Object obj)
          Called once to initialize the function
 Object perform(Object obj)
          This is the main method of a Function Component.
 Object performOperation(Object work, String operation)
          This method invokes an operation in the target AssemblyLine.
 Object performOperation(Object work, String operation, Entry opentry)
           
 void terminate()
          This method frees any resources allocated.
 boolean updateSchema(FunctionConfig config)
          This method modifies the schema in the provided configuration.
 boolean updateSchemaConnector(ConnectorConfig config)
          This method modifies the schema in the provided configuration.
 
Methods inherited from class com.ibm.di.fc.Function
debug, getConfiguration, getContext, getLog, getParam, getUI, initialize, logmsg, setConfiguration, setContext, setLog, setParam, verifyInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASSEMBLYLINE

public static final String ASSEMBLYLINE
See Also:
Constant Field Values

SERVER

public static final String SERVER
See Also:
Constant Field Values

CONFIG

public static final String CONFIG
See Also:
Constant Field Values

CYCLE_MODE

public static final String CYCLE_MODE
See Also:
Constant Field Values

TCB

public static final String TCB
See Also:
Constant Field Values

CUSTOM_SEC

public static final String CUSTOM_SEC
See Also:
Constant Field Values

USE_TCB_ATTRS

public static final String USE_TCB_ATTRS
See Also:
Constant Field Values

SHARE_LOG

public static final String SHARE_LOG
See Also:
Constant Field Values

OPERATION

public static final String OPERATION
See Also:
Constant Field Values

OPERATION_INIT_PREFIX

public static final String OPERATION_INIT_PREFIX
See Also:
Constant Field Values
Constructor Detail

AssemblyLineFC

public AssemblyLineFC()
Method Detail

perform

public Object perform(Object obj)
               throws Exception
Description copied from interface: FunctionInterface
This is the main method of a Function Component. This method is called for the Function Component to actually do its job. The implementation of this methods performs the function which the Function Component was created to do.

Parameters:
obj - the initial work entry for the AssemblyLine being executed (an object of type com.ibm.di.entry.Entry)
Returns:
the result entry of the AssemblyLine
Throws:
Exception - An exception is thrown if this method fails.

performOperation

public Object performOperation(Object work,
                               String operation)
                        throws Exception
This method invokes an operation in the target AssemblyLine.

Parameters:
work - The work entry
operation - The operation to invoke
Returns:
The work entry from the target AssemblyLine
Throws:
Exception

performOperation

public Object performOperation(Object work,
                               String operation,
                               Entry opentry)
                        throws Exception
Throws:
Exception

getTCB

public TaskCallBlock getTCB()
                     throws Exception
Returns the TaskCallBlock to use before starting an instance. Currently, you cannot provide a TCB when cycling a remote AL.

Throws:
Exception

initialize

public void initialize(Object obj)
                throws Exception
Called once to initialize the function

Specified by:
initialize in interface FunctionInterface
Overrides:
initialize in class Function
Parameters:
obj - this parameter is ignored
Throws:
Exception - An exception is thrown if this method fails.

connectServer

public Session connectServer(String server)
                      throws Exception
Establish a server connection.

Throws:
Exception

getConfigInstance

public ConfigInstance getConfigInstance(String ci)
                                 throws Exception
Throws:
Exception

getSession

public Session getSession()

terminate

public void terminate()
               throws Exception
This method frees any resources allocated. If in manual mode, the AssemblyLine will also be terminated gracefully.

Specified by:
terminate in interface FunctionInterface
Overrides:
terminate in class Function
Throws:
Exception - An exception is thrown if this method fails.

updateSchema

public boolean updateSchema(FunctionConfig config)
                     throws Exception
This method modifies the schema in the provided configuration. The intent is to allow the FC to provide a schema definition dynamically based on a given configuration.

Specified by:
updateSchema in interface FunctionInterface
Overrides:
updateSchema in class Function
Throws:
Exception

updateSchemaConnector

public boolean updateSchemaConnector(ConnectorConfig config)
                              throws Exception
This method modifies the schema in the provided configuration. The intent is to allow the FC to provide a schema definition dynamically based on a given configuration.

Parameters:
config - The connector configuration
Returns:
Returns true when the update is completed.
Throws:
Exception - An exception is thrown if this method fails.

getVersion

public String getVersion()
Return version information

Returns:
The version value