com.ibm.di.server
Class AssemblyLineComponent

java.lang.Object
  extended by com.ibm.di.server.AssemblyLineComponent
Direct Known Subclasses:
AttributeMapComponent, BranchingComponent, CSDeltaTaskComponent, DeltaTaskComponent, EndBranchComponent, EndLoopComponent, FunctionComponent, ReplyChannelComponent, ScriptComponent

public class AssemblyLineComponent
extends Object

This class is used by the AssemblyLine (AssemblyLine) to wrap a Connector object and provide additional functionality over the underlying Connector object. All attribute mapping and hook handling is performed by this class.

The underlying Connector object is exposed as a property called connector. This class is also the root class of a hierarchy of classes which represent components which can be hosted in an AssemblyLine (for example Function Components, Script Components, Branch Components, Loop Components, etc.)


Field Summary
protected  AttributeMapping addmap
           
static String CHECKPOINT_GETS
           
protected  ConnectorConfig config
          This is our configuration (with attribute maps, hooks etc ...)
protected  RawConnectorConfig connConfig
          This is the configuration of the ConnectorInterface
 ConnectorInterface connector
          This is the connector we are working with.
protected  ConnectorPool connPool
          Holds the Connector Pool object when a pooled Connector is used
protected  AttributeMapping handler
          This is the object performing hooks
protected  AttributeMapping imap
          These are the objects performing input and output attribute mapping
protected static String INITIALIZE
           
protected  Log log
          This is the Log object we use for logging
protected  AttributeMapping modmap
           
protected  String name
          This is the connector name as given by the AssemblyLine
protected  TaskInterface parent
          This is the parent task (AssemblyLine)
protected  boolean pooledConnector
          Indicates whether this Connector is got from a Connector Pool
protected  long restartCycle
          This is the number of cycles to skip if we are doing a simple restart for an Iterator
protected  boolean reusingConnector
          Flag to avoid closing reused connector
protected static String SELECT
           
 TaskStatistics stats
          This is the statistics object for the connector
 
Constructor Summary
AssemblyLineComponent()
          Empty Constructor for the AssemblyLineComponent object
AssemblyLineComponent(TaskInterface parent, String name, ConnectorConfig config, ConnectorInterface conn)
          Constructor for the AssemblyLineComponent object
AssemblyLineComponent(TaskInterface parent, String name, ConnectorConfig config, ConnectorInterface conn, boolean forceRuntime)
           
 
Method Summary
 void add(Entry meta)
          This method implements the AddOnly mode operation.
 void callreply(Entry meta)
          This method implements the CallReply mode operation.
 boolean checkInitialize()
          Checks whether the connector needs to be (re)initialized or not.
 boolean checkTerminate()
          Checks whether the connector should be terminated (e.g.
 void close()
          This method closes the connector (connector.terminate()) and calls the before/after close hooks.
 void debug(String msg)
          Write a message to the logfile prefixed by this connector's name
 void delete(Entry meta)
          This method implements the Delete mode operation.
 void deleteEntry(Entry meta)
          This method calls the delete method.
 void delta(Entry meta)
          This method implements the Delta mode operation.
 void doConnectorInitialize()
          This method calls the appropriate hooks and the connector's initialize method.
 void doConnectorTerminate()
          This method calls the appropriate hooks and the connector's terminate method.
 void dumpEntry(Entry meta)
          Deprecated. replaced byadd(Entry)
protected  void dumpObjects(Entry conn, Entry work, Entry current)
           
 void expandParameters(BaseConfiguration cf)
          Deprecated.
 BaseConfiguration getBaseConfiguration()
          This method returns the BaseConfiguration
 Object getConfig(String param)
          This method returns the configuration value for a parameter
 ConnectorConfig getConfiguration()
          This method returns the Connector configuration
 ConnectorInterface getConnector()
          Returns the ConnectorInterface we are working with
 Object getConnectorParam(String param)
          This method returns the configuration value for the ConnectorInterface's parameter.
 SearchCriteria getCriteria()
          This method returns the link criteria
 Entry getCurrent()
          Gets the current attribute of the AssemblyLineComponent object
 boolean getDebug()
          This method returns the debug mode flag.
 int getDuplicateEntryCount()
          Gets the count of duplicate Entries found by the last findEntry by the ConnectorInterface
 Entry getFirstDuplicateEntry()
          Gets the first Duplicate Entry from the ConnectorInterface.
 AttributeMapping getHandler()
           
 Entry getLastEntry()
          This method returns the last entry read and mapped.
 Entry getLastReadEntry()
          This method returns the last entry read from the connector.
 Log getLog()
          Returns the log object
 String getName()
          This method returns the name assigned to the Connector by the AssemblyLine.
 Entry getnext()
          The method returns the next entry from the connector.
 Entry getnext(Entry work)
          The method returns the next entry from the connector.
 ConnectorInterface getnextClient()
          The method returns the next client from the connector.
 Entry getNextDuplicateEntry()
          Gets the next Duplicate Entry from the ConnectorInterface.
 Entry getRestartInfoEntry()
          This method returns the connector's restart info entry.
 TaskStatistics getStats()
          Gets the stats attribute of the AssemblyLineComponent object
 int getType()
          This method returns the mode in which we are executing (e.g.
 void handleException(String aOper, Throwable e, Entry meta)
          This method is called by the AssemblyLine.
 void handleSuccess(String oper, Entry meta)
          This method is called by the AssemblyLine if the operation oper is successful.
 void initialize()
          This method initializes the underlying connector and registers the script beans in the ScriptEngine context.
 boolean isCheckpointRestartEnabled()
           
 boolean isDeltaMode()
          Returns true if we are in Delta mode.
 boolean isEnabled()
          Returns true if this Component is enabled in this AssemblyLine
 boolean isExceptionFatal(Exception e)
          Returns true if an exception is fatal
 void logmsg(String msg)
          Write a message to the logfile prefixed by this connector's name
 Entry lookup(Entry meta)
          The method is called to lookup an entry using the configured Link Criteria.
 Entry lookup(String attribute, String value)
          The method is called to lookup an entry using exact matching for attribute and value.
 Entry mapEntry(Entry work, Entry conn)
          The method is called to map an entry using the configured input attribute map.
 void modify(Entry old, Entry meta)
          This method implements the Modify operation (called by Update if the entry exists)
 void pushback(Entry entry)
          This method pushes an entry back to the connector.
 boolean reconnect()
          Cause the underlying ConnectorInterface to reconnect to it's data source
 void reply(Entry meta)
          This method is used to send a reply entry to a connector
 void setConnectorParam(String param, Object value)
          This method sets the configuration value for the ConnectorInterface's parameter.
 void setCriteria(SearchCriteria mySearchCrit)
          This method sets the link criteria for this AssemblyLineComponent
 boolean setCriteria(SearchCriteria mySearchCrit, Entry work)
          This method sets the link criteria template for this AssemblyLineComponent, and then expands the template using the given work Entry.
 void setCurrent(Entry current)
          Sets the current attribute of the AssemblyLineComponent object
 void setDebug(boolean debug)
          This method sets the the debug mode flag.
 void setDuplicateEntryCount(int maxdup)
          Sets the max number of duplicate entries for the ConnectorInterface
 void setErrorObject(String oper, String reason)
          Deprecated. Not used anymore
 void setName(String name)
           
 void setRestartInfoEntry(ALState state, Entry rsi, int restartPoint)
           
 boolean trigger(String oper)
          Calls the hook named oper
 boolean trigger(String oper, Entry work)
          Calls the hook named oper, declaring work as the corresponding bean.
 boolean trigger(String oper, Entry work, Entry conn)
          Calls the hook named oper, declaring work and conn as the corresponding beans.
 void update(Entry meta)
          This method implements the Update mode operation.
 void verifySchema(Entry entry, boolean input)
          Verify contents of an entry according to connector's schema definition
 boolean wasConfigurationModified()
          Returns true if the connection configuration has been modified since last call.
 boolean willExecute(Entry work)
          Return true/false if this component should be executed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECKPOINT_GETS

public static final String CHECKPOINT_GETS
See Also:
Constant Field Values

INITIALIZE

protected static final String INITIALIZE
See Also:
Constant Field Values

SELECT

protected static final String SELECT
See Also:
Constant Field Values

connector

public ConnectorInterface connector
This is the connector we are working with. See getConnector()


stats

public TaskStatistics stats
This is the statistics object for the connector


name

protected String name
This is the connector name as given by the AssemblyLine


parent

protected TaskInterface parent
This is the parent task (AssemblyLine)


reusingConnector

protected boolean reusingConnector
Flag to avoid closing reused connector


imap

protected AttributeMapping imap
These are the objects performing input and output attribute mapping


addmap

protected AttributeMapping addmap

modmap

protected AttributeMapping modmap

handler

protected AttributeMapping handler
This is the object performing hooks


config

protected ConnectorConfig config
This is our configuration (with attribute maps, hooks etc ...)


connConfig

protected RawConnectorConfig connConfig
This is the configuration of the ConnectorInterface


log

protected Log log
This is the Log object we use for logging


restartCycle

protected long restartCycle
This is the number of cycles to skip if we are doing a simple restart for an Iterator


pooledConnector

protected boolean pooledConnector
Indicates whether this Connector is got from a Connector Pool


connPool

protected ConnectorPool connPool
Holds the Connector Pool object when a pooled Connector is used

Constructor Detail

AssemblyLineComponent

public AssemblyLineComponent(TaskInterface parent,
                             String name,
                             ConnectorConfig config,
                             ConnectorInterface conn)
                      throws Exception
Constructor for the AssemblyLineComponent object

Parameters:
parent - The AssemblyLine or EventHandler using this component
name - The name of this connector
config - The configuration for this connector
conn - An optional connector to use if we need a (runtime provided) connector
Throws:
Exception - Any exception that might occur while loading the config

AssemblyLineComponent

public AssemblyLineComponent(TaskInterface parent,
                             String name,
                             ConnectorConfig config,
                             ConnectorInterface conn,
                             boolean forceRuntime)
                      throws Exception
Throws:
Exception

AssemblyLineComponent

public AssemblyLineComponent()
Empty Constructor for the AssemblyLineComponent object

Method Detail

setCurrent

public void setCurrent(Entry current)
Sets the current attribute of the AssemblyLineComponent object

Parameters:
current - The new current value

setDebug

public void setDebug(boolean debug)
This method sets the the debug mode flag.

Parameters:
debug - True to enable debug, false to disable

setErrorObject

public void setErrorObject(String oper,
                           String reason)
Deprecated. Not used anymore

Declare an error object in the script engine

Parameters:
oper - The new errorObject value
reason - The new errorObject value

setDuplicateEntryCount

public void setDuplicateEntryCount(int maxdup)
Sets the max number of duplicate entries for the ConnectorInterface

Parameters:
maxdup - The new maximum

getName

public String getName()
This method returns the name assigned to the Connector by the AssemblyLine.

Returns:
The name of this Connector (in scripting terms)

setName

public void setName(String name)

getCurrent

public Entry getCurrent()
Gets the current attribute of the AssemblyLineComponent object

Returns:
The current value

getConfiguration

public ConnectorConfig getConfiguration()
This method returns the Connector configuration


getBaseConfiguration

public BaseConfiguration getBaseConfiguration()
This method returns the BaseConfiguration


getConfig

public Object getConfig(String param)
This method returns the configuration value for a parameter

Parameters:
param - The parameter name
Returns:
The object associated with parameter name

getConnectorParam

public Object getConnectorParam(String param)
This method returns the configuration value for the ConnectorInterface's parameter.

Parameters:
param - The parameter name
Returns:
The object associated with parameter name

setConnectorParam

public void setConnectorParam(String param,
                              Object value)
This method sets the configuration value for the ConnectorInterface's parameter.

Parameters:
param - The parameter name
value - The parameter value

getConnector

public ConnectorInterface getConnector()
Returns the ConnectorInterface we are working with

Returns:
The Connector we are working with

getDebug

public boolean getDebug()
This method returns the debug mode flag.

Returns:
True if debug is enabled, false otherwise

getCriteria

public SearchCriteria getCriteria()
This method returns the link criteria

Returns:
The link criteria of this AssemblyLineComponent

setCriteria

public void setCriteria(SearchCriteria mySearchCrit)
This method sets the link criteria for this AssemblyLineComponent

Parameters:
mySearchCrit - The link criteria to set

setCriteria

public boolean setCriteria(SearchCriteria mySearchCrit,
                           Entry work)
This method sets the link criteria template for this AssemblyLineComponent, and then expands the template using the given work Entry. If the template is successfully expanded, the method will return true.

Parameters:
mySearchCrit - The Sriteria to set
work - The Entry to use for expansion.
Returns:
true if the link criteria was successfully expanded.

getType

public int getType()
This method returns the mode in which we are executing (e.g. Iterator, update etc..). public final static int TYPE_ITERATOR = 0; public final static int TYPE_UPDATE = 1; public final static int TYPE_LOOKUP = 2; public final static int TYPE_DELETE = 3; public final static int TYPE_ADDONLY = 4; public final static int TYPE_CALLREPLY = 5; public final static int TYPE_SCRIPT = 6; public final static int TYPE_FUNCTION = 7; public final static int TYPE_BRANCH = 8; public final static int TYPE_REPLYCHANNEL = 9; public final static int TYPE_SERVER = 10; public final static int TYPE_DELTA = 11; public final static int TYPE_LOOP = 12; public final static int TYPE_ATTRIBUTEMAP = 13; public final static int TYPE_SWITCH = 14; public final static int TYPE_CASE = 15;

Returns:
The integer value corresponding to the execution mode

isDeltaMode

public boolean isDeltaMode()
Returns true if we are in Delta mode.


getLastReadEntry

public Entry getLastReadEntry()
This method returns the last entry read from the connector.

Returns:
The last input entry (unmapped)

getLastEntry

public Entry getLastEntry()
This method returns the last entry read and mapped.

Returns:
The last input entry (mapped)

getnextClient

public ConnectorInterface getnextClient()
                                 throws Exception
The method returns the next client from the connector.

Returns:
The next client or null if there are no more clients
Throws:
Exception - Errors that may occur

getnext

public Entry getnext()
              throws Exception
The method returns the next entry from the connector.

Returns:
The next input entry or null if there are no more entries
Throws:
Exception - Errors that may occur

getnext

public Entry getnext(Entry work)
              throws Exception
The method returns the next entry from the connector. It is called by the AssemblyLine if we are working in Iterator mode.

Parameters:
work - The work entry to fill in
Returns:
The work entry filled with the next input entry, or null if there are no more entries
Throws:
Exception - Errors that may occur

getStats

public TaskStatistics getStats()
Gets the stats attribute of the AssemblyLineComponent object

Returns:
The stats value

getLog

public Log getLog()
Returns the log object

Returns:
The stats value

getHandler

public AttributeMapping getHandler()

isExceptionFatal

public boolean isExceptionFatal(Exception e)
Returns true if an exception is fatal

Parameters:
e - The exception to check
Returns:
True if the exception is fatal

getDuplicateEntryCount

public int getDuplicateEntryCount()
Gets the count of duplicate Entries found by the last findEntry by the ConnectorInterface

Returns:
The duplicateEntryCount value

getFirstDuplicateEntry

public Entry getFirstDuplicateEntry()
                             throws Exception
Gets the first Duplicate Entry from the ConnectorInterface. This function also resets the implicit pointer to the next Entry.

Returns:
The firstDuplicateEntry value
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

getNextDuplicateEntry

public Entry getNextDuplicateEntry()
                            throws Exception
Gets the next Duplicate Entry from the ConnectorInterface. This function also moves an implicit pointer to the next Entry.

Returns:
The nextDuplicateEntry value, null means no more values
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

isEnabled

public boolean isEnabled()
Returns true if this Component is enabled in this AssemblyLine

Returns:
The enabled value

close

public void close()
           throws Exception
This method closes the connector (connector.terminate()) and calls the before/after close hooks.

Throws:
Exception

willExecute

public boolean willExecute(Entry work)
                    throws Exception
Return true/false if this component should be executed. Also calls the "Before Execute" hook.

Parameters:
work - The current work Entry
Returns:
True if this component is enabled
Throws:
Exception - Any exception thrown by the executed hook

initialize

public void initialize()
                throws Exception
This method initializes the underlying connector and registers the script beans in the ScriptEngine context.

Throws:
Exception - any exception, which occurs during the initialization of the component and is not handled by the reconnect mechanism or the error hooks; it is also possible that the exception is thrown by some of the initialize hooks

pushback

public void pushback(Entry entry)
This method pushes an entry back to the connector. The entry is returned the next time connector.getNextEntry() is called.

Parameters:
entry - The entry to push back

doConnectorInitialize

public void doConnectorInitialize()
                           throws Exception
This method calls the appropriate hooks and the connector's initialize method.

Throws:
Exception

doConnectorTerminate

public void doConnectorTerminate()
                          throws Exception
This method calls the appropriate hooks and the connector's terminate method.

Throws:
Exception

lookup

public Entry lookup(String attribute,
                    String value)
             throws Exception
The method is called to lookup an entry using exact matching for attribute and value.

Parameters:
attribute - The attribute name to search
value - The attribute value
Returns:
The entry found or null if no entries or more than one entry was found.
Throws:
Exception - Any exceptions thrown by the underlying connector

lookup

public Entry lookup(Entry meta)
             throws Exception
The method is called to lookup an entry using the configured Link Criteria. The link criteria is applied using meta as source for variable substitution. If you allow duplicate entries by configuration, the method will return null only when no entries have been found.

Parameters:
meta - The entry object providing values for variable substitution.
Returns:
The entry found or null if no entries or more than one entry was found.
Throws:
Exception - the component is not initialized or the underlying Connector raised an error or some of the user-defined hooks raised an error

deleteEntry

public void deleteEntry(Entry meta)
                 throws Exception
This method calls the delete method. It is included since JavaScript and possibly other scripting languages choke on the "delete" keyword.

Parameters:
meta - The work object to use for the link criteria
Throws:
Exception - Any Exception
See Also:
delete( Entry )

delete

public void delete(Entry meta)
            throws Exception
This method implements the Delete mode operation.

Parameters:
meta - The work object to use for the link criteria
Throws:
Exception - the component is not initialized or the underlying Connector raised an error or some of the user-defined hooks raised an error

update

public void update(Entry meta)
            throws Exception
This method implements the Update mode operation.

Parameters:
meta - The work entry
Throws:
Exception - the component is not initialized or the underlying Connector raised an error or some of the user-defined hooks raised an error

modify

public void modify(Entry old,
                   Entry meta)
            throws Exception
This method implements the Modify operation (called by Update if the entry exists)

Parameters:
old - The current entry in the destination system
meta - The new entry to use in the attribute map
Throws:
Exception - Any Exception

add

public void add(Entry meta)
         throws Exception
This method implements the AddOnly mode operation.

Parameters:
meta - The work entry to add
Throws:
Exception - the component is not initialized or the underlying Connector raised an error or some of the user-defined hooks raised an error

reply

public void reply(Entry meta)
           throws Exception
This method is used to send a reply entry to a connector

Parameters:
meta - The work entry to add
Throws:
Exception - the component is not initialized or the underlying Connector raised an error or some of the user-defined hooks raised an error

callreply

public void callreply(Entry meta)
               throws Exception
This method implements the CallReply mode operation.

Parameters:
meta - The work entry to send
Throws:
Exception - the component is not initialized or the underlying Connector raised an error or some of the user-defined hooks raised an error

delta

public void delta(Entry meta)
           throws Exception
This method implements the Delta mode operation.

Parameters:
meta - The delta entry
Throws:
Exception - Any Exception

dumpEntry

public void dumpEntry(Entry meta)
               throws Exception
Deprecated. replaced byadd(Entry)

Parameters:
meta - an Entry to be added to the data source by the Connector
Throws:
Exception - problem while adding the Entry to the data source

logmsg

public void logmsg(String msg)
Write a message to the logfile prefixed by this connector's name

Parameters:
msg - The message to write

debug

public void debug(String msg)
Write a message to the logfile prefixed by this connector's name

Parameters:
msg - The message to write

handleException

public void handleException(String aOper,
                            Throwable e,
                            Entry meta)
                     throws Exception
This method is called by the AssemblyLine. The oper is any of the standard modes. The mode specific error hook is called first, then the "default" error hook is called.

Parameters:
aOper - Hook prefix
e - The error causing this hook to be called, or null for no error
meta - The work entry
Throws:
Exception - Throws the parameter e if we cannot or do not want to handle it, or an Exception from the Hooks.

handleSuccess

public void handleSuccess(String oper,
                          Entry meta)
                   throws Exception
This method is called by the AssemblyLine if the operation oper is successful. The mode specific success hook is called first, then the "default" success hook is called.

Parameters:
oper - Hook prefix
meta - The work entry
Throws:
Exception - Any Exception from the Hooks

trigger

public boolean trigger(String oper,
                       Entry work,
                       Entry conn)
                throws Exception
Calls the hook named oper, declaring work and conn as the corresponding beans. The trigger function calls one of the AssemblyLine hooks defined for this Connector using the provided conn/work.

Parameters:
oper - Name of the hook to call
work - This will be the work bean in the hook
conn - This will be the conn bean in the hook
Returns:
True if the hook was executed, false if the hook is not defined or disabled.
Throws:
Exception - Any exception thrown by the execution of the hook

trigger

public boolean trigger(String oper,
                       Entry work)
                throws Exception
Calls the hook named oper, declaring work as the corresponding bean. The trigger function calls one of the AssemblyLine hooks defined for this Connector using the provided work.

Parameters:
oper - Name of the hook to call
work - This will be the work bean in the hook
Returns:
True if the hook was executed, false if the hook is not defined or disabled.
Throws:
Exception - Any exception thrown by the execution of the hook

trigger

public boolean trigger(String oper)
                throws Exception
Calls the hook named oper

Parameters:
oper - Name of the hook to call
Returns:
True if the hook was executed, false if the hook is not defined or disabled.
Throws:
Exception - Any exception thrown by the execution of the hook

expandParameters

public void expandParameters(BaseConfiguration cf)
                      throws Exception
Deprecated.

Throws:
Exception

verifySchema

public void verifySchema(Entry entry,
                         boolean input)
                  throws Exception
Verify contents of an entry according to connector's schema definition

Throws:
Exception

getRestartInfoEntry

public Entry getRestartInfoEntry()
                          throws Exception
This method returns the connector's restart info entry.

Throws:
Exception

isCheckpointRestartEnabled

public boolean isCheckpointRestartEnabled()
                                   throws Exception
Throws:
Exception

setRestartInfoEntry

public void setRestartInfoEntry(ALState state,
                                Entry rsi,
                                int restartPoint)
                         throws Exception
Throws:
Exception

dumpObjects

protected void dumpObjects(Entry conn,
                           Entry work,
                           Entry current)

reconnect

public boolean reconnect()
                  throws Exception
Cause the underlying ConnectorInterface to reconnect to it's data source

Throws:
Exception

mapEntry

public Entry mapEntry(Entry work,
                      Entry conn)
               throws Exception
The method is called to map an entry using the configured input attribute map.

Parameters:
work - The work entry
conn - The conn entry
Returns:
The mapped entry
Throws:
Exception - problem while mapping the entry

checkInitialize

public boolean checkInitialize()
                        throws Exception
Checks whether the connector needs to be (re)initialized or not.

Returns:
true if connector was (re)initialized
Throws:
Exception

checkTerminate

public boolean checkTerminate()
                       throws Exception
Checks whether the connector should be terminated (e.g. init option = always).

Returns:
true if connector was terminated
Throws:
Exception

wasConfigurationModified

public boolean wasConfigurationModified()
Returns true if the connection configuration has been modified since last call.