com.ibm.di.trigger
Class Trigger

java.lang.Object
  extended by java.lang.Thread
      extended by com.ibm.di.server.Monitor
          extended by com.ibm.di.trigger.Trigger
All Implemented Interfaces:
VersionInfoInterface, TriggerInterface, Runnable
Direct Known Subclasses:
GenericTrigger, TimerTrigger

public class Trigger
extends Monitor
implements TriggerInterface, VersionInfoInterface

The Trigger class is a base class for triggers (old-time EventHandlers) and implements basic common functionalilty. Triggers are also refered to as primitive EventHandlers. This is a legacy class and should not be used as a base class for development of EventHandler implementation classes. Instead the com.ibm.di.eventhandler.Switchboard class should be used.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  ScriptEngine bsf
           
protected  RSInterface parent
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Trigger()
           
 
Method Summary
 void addEventListener(ActionListener l)
          Adds a new action listener.
 void callFunction(String func, Object[] param)
          Using the trigger's Script Engine it calls a function with the specified name, passing to it the specified parameters
protected  void close()
          Cleanup on termination.
 void declareBean(String name, Object obj)
           
 void dump(Object o)
          Dumps the object passed using the trigger's logger.
 void dumpEntry(Entry e)
          Dumps the Entry object passed using the trigger's logger.
 void execScript()
           
 boolean fireEvent(ActionEvent e)
          Triggers the action listeners using the specified action event.
 Object getConfig()
          Returns the trigger configuration.
 EventHandlerListener getEventHandlerListener()
           
 boolean getExitRequested()
          Returns the value of the exit requested flag.
 Log getLog()
          Returns the trigger's logger object.
 String getLogCategory()
          Returns the log4j category name used by this Trigger.
 String getParam(String p1)
          Returns the value of a connection config parameter.
 String[][] getParameters()
          Returns the trigger's parameters.
 RSInterface getParent()
          Returns the trigger's parent RS - this is a reference to the TDI Server in which the trigger executes.
 TaskStatistics getStats()
          Return the statistics object
 String getVersion()
           
 void includeAllScripts()
          Includes all scripts from the script library marked for auto-include.
 ParserInterface loadParser(String name)
          Creates a parser object with the specified name.
 void logmonitor(String msg)
           
 void logmsg(String msg)
          Logs a message to the trigger's logger using INFO log level.
 void logmsg(String level, String msg)
          This method logs a message with the specified level to the log.
 void removeEventHandlerListener()
           
 void removeEventListener(ActionListener l)
          Removes the specified action listener from the list of the action listeners.
 void setConfig(Object cfg)
          Sets the trigger's configuration.
 void setEventHandlerListener(EventHandlerListener listener)
           
 void setExitRequested(boolean value)
          Sets the exit requested flag to the value specified and then interrupts the trigger.
 boolean setLogCategory(String categoryName)
          Sets the log4j category name used when requesting a logger.
 void setParam(String p1, String p2)
          Sets a value to a connection config parameter.
 void setParameters(String[] parameter)
          Sets the trigger's parameters.
 void setParent(RSInterface o)
          Sets the trigger's parent RS - this is a reference to the TDI Server in which the trigger executes.
 void undeclareBean(String name)
           
 
Methods inherited from class com.ibm.di.server.Monitor
addActionListener, addThread, allThreadsStopped, fireListener, removeActionListener, removeThread, runningALs, runningEHs, setMonitorMessage, threadStarted, threadStopped
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ibm.di.trigger.TriggerInterface
getName, setName, start
 

Field Detail

parent

protected RSInterface parent

bsf

protected ScriptEngine bsf
Constructor Detail

Trigger

public Trigger()
Method Detail

getParameters

public String[][] getParameters()
Returns the trigger's parameters.


setParameters

public void setParameters(String[] parameter)
Sets the trigger's parameters.


getLog

public Log getLog()
Returns the trigger's logger object.

Specified by:
getLog in interface TriggerInterface

setParent

public void setParent(RSInterface o)
Sets the trigger's parent RS - this is a reference to the TDI Server in which the trigger executes.

Specified by:
setParent in interface TriggerInterface
Parameters:
o - The new parent value

getParent

public RSInterface getParent()
Returns the trigger's parent RS - this is a reference to the TDI Server in which the trigger executes.

Specified by:
getParent in interface TriggerInterface
Returns:
The parent value

setConfig

public void setConfig(Object cfg)
Sets the trigger's configuration.

Specified by:
setConfig in interface TriggerInterface
Parameters:
cfg - The new config value

dump

public void dump(Object o)
Dumps the object passed using the trigger's logger.


dumpEntry

public void dumpEntry(Entry e)
Dumps the Entry object passed using the trigger's logger.


getConfig

public Object getConfig()
Returns the trigger configuration.

Specified by:
getConfig in interface TriggerInterface
Returns:
The config value

getParam

public String getParam(String p1)
Returns the value of a connection config parameter.


setParam

public void setParam(String p1,
                     String p2)
Sets a value to a connection config parameter.


getStats

public TaskStatistics getStats()
Return the statistics object

Specified by:
getStats in interface TriggerInterface

loadParser

public ParserInterface loadParser(String name)
                           throws Exception
Creates a parser object with the specified name.

Throws:
Exception

execScript

public void execScript()
                throws Exception
Throws:
Exception

callFunction

public void callFunction(String func,
                         Object[] param)
                  throws Exception
Using the trigger's Script Engine it calls a function with the specified name, passing to it the specified parameters

Throws:
Exception

declareBean

public void declareBean(String name,
                        Object obj)
                 throws Exception
Throws:
Exception

undeclareBean

public void undeclareBean(String name)

logmsg

public void logmsg(String level,
                   String msg)
This method logs a message with the specified level to the log.

Parameters:
level - Loglevel. Legal values are FATAL, ERROR, WARN, INFO, DEBUG. Unrecognized keyword means DEBUG.
msg - The message

logmsg

public void logmsg(String msg)
Logs a message to the trigger's logger using INFO log level.


logmonitor

public void logmonitor(String msg)

setEventHandlerListener

public void setEventHandlerListener(EventHandlerListener listener)
Specified by:
setEventHandlerListener in interface TriggerInterface

getEventHandlerListener

public EventHandlerListener getEventHandlerListener()
Specified by:
getEventHandlerListener in interface TriggerInterface

removeEventHandlerListener

public void removeEventHandlerListener()
Specified by:
removeEventHandlerListener in interface TriggerInterface

addEventListener

public void addEventListener(ActionListener l)
Adds a new action listener.


removeEventListener

public void removeEventListener(ActionListener l)
Removes the specified action listener from the list of the action listeners.


fireEvent

public boolean fireEvent(ActionEvent e)
Triggers the action listeners using the specified action event.


includeAllScripts

public void includeAllScripts()
                       throws Exception
Includes all scripts from the script library marked for auto-include.

Throws:
Exception - the underlying ScriptEngine raised an error

getLogCategory

public String getLogCategory()
Returns the log4j category name used by this Trigger.


setLogCategory

public boolean setLogCategory(String categoryName)
Sets the log4j category name used when requesting a logger.

Parameters:
categoryName - The logj4 category name
Returns:
True

getExitRequested

public boolean getExitRequested()
Returns the value of the exit requested flag.


setExitRequested

public void setExitRequested(boolean value)
Sets the exit requested flag to the value specified and then interrupts the trigger.

Specified by:
setExitRequested in interface TriggerInterface
Parameters:
value - The new value of the exitRequested

getVersion

public String getVersion()
Specified by:
getVersion in interface VersionInfoInterface

close

protected void close()
Cleanup on termination. Closes the log used by the Trigger.