|
ABLE 2.3.0 07/13/2005 14:21:00 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectcom.ibm.able.AbleObject
com.ibm.able.AbleDefaultAgent
The AbleDefaultAgent class provides an ABLE agent which can contain other agents and beans and supports event connections to other agents and beans. Most ABLE agents extend this class and override methods as necessary.
When process() is called on an agent, process is called on
each bean in its processList, which is a subset of contained
beans with dataflow enabled in connection sequence. Methods such as
quitAll() and resumeAll() apply to all contained beans.
The AbleDefaultAgent implementation:
AbleEvent.EOF events received from its active
data source for learning agents.
Property change events are fired by the following methods:
setActiveDataSource(boolean) sends an AbleProperty.ActiveDataSource event.setProcessList(java.util.Vector) sends an AbleProperty.ProcessList event.addBean(com.ibm.able.AbleBean) sends an AbleProperty.Beans event, and, if the added
bean is a active data source, an AbleProperty.DataFlowEnabled event.removeBean(com.ibm.able.AbleBean) sends an AbleProperty.Beans event.addUserDefinedFunction(com.ibm.able.AbleUserDefinedFunction) sends an AbleProperty.UserDefinedFunction event.removeUserDefinedFunction(java.lang.String, int) sends an AbleProperty.UserDefinedFunction event.setUserDefinedFunctions(java.util.Hashtable) sends an AbleProperty.UserDefinedFunction event.setProcessList(java.util.Vector) sends an AbleProperty.ProcessList event.
| Field Summary | |
|---|---|
protected boolean |
activeDataSource
Indicates if the agent contains an active data source. |
static java.lang.String |
defaultName
The default name for an AbleDefaultAgent agent. |
protected java.util.Vector |
eventConnections
A list of AbleEventConnection objects managed by this agent. |
protected java.util.Hashtable |
myBeans
The list of AbleBean objects contained by this agent. |
protected long |
numEpochs
An agent that contains a data source listens for AbleEvent.EOF
events. |
protected java.util.Vector |
processList
The list of objects to be processed in order during a process() call. |
protected boolean |
processListOK
Indicates whether the processList needs to be computed. |
protected java.util.Hashtable |
userDefinedFunctions
The list of registered AbleUserDefinedFunction
objects managed by this agent. |
| Fields inherited from class com.ibm.able.AbleObject |
|---|
changed, chgSupport, comment, dataFlowEnabled, destBufferConnections, eventQueue, fileName, inputBuffer, listeners, logger, name, outputBuffer, parent, properties, propertyConnectionMgr, sourceBufferConnections, state, stateChgSupport, trace |
| Constructor Summary | |
|---|---|
AbleDefaultAgent()
Construct an AbleDefaultAgent instance. |
|
AbleDefaultAgent(java.lang.String theName)
Construct an AbleDefaultAgent with the specified name. |
|
AbleDefaultAgent(java.lang.String theName,
java.lang.String theComment)
Construct an AbleDefaultAgent with the specified name and comment. |
|
| Method Summary | |
|---|---|
void |
addBean(AbleBean theAbleBean)
Adds a bean to this container/agent. |
static void |
addBeans(AbleBeanContainer container,
AbleBean[] theBeans)
A convenience method to add a list of beans which calls addBean(AbleBean). |
void |
addEventConnection(AbleEventConnection theConnection)
Adds an event connection. |
void |
addUserDefinedFunction(AbleUserDefinedFunction theUserDefinedFunction)
Adds a specific user-defined function to the master list of user-defined functions. |
protected void |
buildProcessList()
Examine the list of contained beans myBeans for dataflow
connections, building a sequential processing list. |
protected java.lang.String |
clsNm()
Returns the name of this class for easy inclusion in exceptions. |
boolean |
containsBean(AbleBean theAbleBean)
Indicates if a specific bean is present. |
boolean |
containsBean(java.lang.String theName)
Indicates if a bean with a specific name is present. |
boolean |
containsUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
int theArity)
Indicates if the master list of user-defined functions contains a user-defined function with the specified name and arity. |
protected void |
debugTrace(java.lang.String theMessage)
Log a trace message at level Able.TRC_LOW
if Able.Debug is enabled. |
static java.lang.String |
generateUniqueName(AbleBeanContainer container,
AbleBean bean)
Generate a unique bean name by appending an underscore and an integer. |
AbleBean |
getBean(java.lang.String theName)
Returns a bean with a specific name from this container. |
java.util.Vector |
getBeans()
Returns a list of all contained beans. |
AbleDataSource |
getDataSource()
Returns the current active DataSource from the contained beans, null if none. |
java.util.Vector |
getEventConnections()
Returns event connections used by this agent. |
long |
getNumEpochs()
Returns the number of training epochs, which is the number of times an active data source has had all its records processed. |
java.util.Vector |
getProcessList()
Returns the sequential processing list for data buffer processing. |
AbleUserDefinedFunction |
getUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
int theArity)
Returns the specified user-defined function |
java.util.Hashtable |
getUserDefinedFunctions()
Returns the complete master list of user-defined functions registered with this function manager. |
void |
handleAbleEvent(AbleEvent theAbleEvent)
Handles an Able event. |
void |
init()
Initialize the agent. |
void |
initAllBeans()
Initialize all contained beans, and this agent instance itself. |
java.lang.Object |
invokeUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
java.lang.Object[] theArgs)
Invokes the actual method that the named user-defined function represents, passing in the array of argument objects. |
boolean |
isActiveDataSource()
Indicates if this agent has an active data source. |
void |
process()
Performs the main, synchronous, standard processing function performed by this bean. |
void |
propertyChange(java.beans.PropertyChangeEvent theEvent)
Handle a propertyChange event. |
void |
quitAll()
Quits all forms of processing for this bean. |
void |
quitEnabledEventProcessing()
Stop the agent's asynchronous thread of control. |
void |
removeAllBeans()
Removes all beans from this container. |
void |
removeAllConnections()
Removes all Property, Buffer, and Event connections. |
void |
removeAllEventConnections()
Remove all event connections. |
void |
removeBean(AbleBean theAbleBean)
Removes a bean from this container, and sets the bean's parent to null. |
void |
removeBean(java.lang.String theName)
A convenience method to remove a bean by name which calls removeBean(AbleBean). |
static void |
removeBeans(AbleBeanContainer container,
AbleBean[] theBeans)
A convenience method to remove a list of beans which calls removeBean(AbleBean). |
void |
removeEventConnection(AbleEventConnection theConnection)
Removes an event connection. |
void |
removeUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
int theArity)
Removes the named user-defined function from the master list of user-defined functions. |
void |
reset()
Reset the agent to its "initialized" state. |
void |
resetAllBeans()
Reset all beans in this container agent as required by AbleBeanContainer. |
void |
resumeAll()
Resumes all of the bean's suspended asynchronous threads of control. |
void |
setActiveDataSource(boolean theState)
Sets the flag indicating if this agent contains an active data source. |
void |
setDataFlowEnabled(boolean theDataFlowEnabledState)
Sets the data flow processing state of the bean. |
void |
setProcessList(java.util.Vector theProcessList)
Set the sequential list of beans to process. |
void |
setUserDefinedFunctions(java.util.Hashtable theUserDefinedFunctions)
Sets the complete master list of user-defined functions for this function manager. |
void |
suspendAll()
Temporarily suspends all of the bean's asynchronous threads of control. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.ibm.able.AbleBean |
|---|
getComment, getLogger, getName, getParent, getProperties, getProperty, getState, getTraceLogger, init, isChanged, process, removeProperty, setChanged, setComment, setLogger, setName, setParent, setProperties, setProperty, setState, setTraceLogger |
| Methods inherited from interface com.ibm.able.AbleEventListenerManager |
|---|
addAbleEventListener, dataChanged, getAbleEventListeners, notifyAbleEventListeners, removeAbleEventListener |
| Methods inherited from interface com.ibm.able.AbleEventQueueProcessor |
|---|
processAbleEvent, processNoEventProcessingEnabledSituation, processTimerEvent |
| Methods inherited from interface com.ibm.able.AblePropertyChangeManager |
|---|
addPropertyChangeListener, addPropertyConnection, getPropertyChangeListeners, getPropertyConnectionManager, removeAllPropertyConnections, removePropertyChangeListener, removePropertyConnection |
| Methods inherited from interface com.ibm.able.AbleSerializable |
|---|
getFileName, restoreFromFile, restoreFromFile, saveToFile, saveToFile, setFileName |
| Methods inherited from interface com.ibm.able.AbleBeanContainer |
|---|
getName |
| Field Detail |
public static final java.lang.String defaultName
protected java.util.Hashtable myBeans
protected boolean activeDataSource
protected java.util.Vector eventConnections
protected transient java.util.Vector processList
process() call.
protected transient boolean processListOK
protected long numEpochs
AbleEvent.EOF
events. It increments the epoch count for each such event. This is
used by machine learning agents.
This field is initialized to zero (0).
protected java.util.Hashtable userDefinedFunctions
AbleUserDefinedFunction
objects managed by this agent.
| Constructor Detail |
public AbleDefaultAgent()
throws AbleException
AbleException - If an error occurs.
public AbleDefaultAgent(java.lang.String theName)
throws AbleException
theName - The name of the agent.
AbleException - If an error occurs.
public AbleDefaultAgent(java.lang.String theName,
java.lang.String theComment)
throws AbleException
theName - The name of the agent.theComment - A comment for the agent.
AbleException - If an error occurs.| Method Detail |
public void setActiveDataSource(boolean theState)
throws AbleException
AbleAgent
setActiveDataSource in interface AbleAgenttheState - The state is true if the agent contains
an active data source, and false otherwise.
AbleException - If an error occurs.
public boolean isActiveDataSource()
throws AbleException
AbleAgent
isActiveDataSource in interface AbleAgenttrue if agent contains an active data source;
false otherwise.
AbleException - If an error occurs.
public AbleDataSource getDataSource()
throws AbleException
AbleAgent
getDataSource in interface AbleAgentAbleException - If an error occurs.public java.util.Vector getEventConnections()
AbleAgent
getEventConnections in interface AbleAgentAbleEventConnection
public void addEventConnection(AbleEventConnection theConnection)
throws AbleException
AbleAgent
addEventConnection in interface AbleAgenttheConnection - The connection to add.
AbleException - If an error occurs.
public void removeEventConnection(AbleEventConnection theConnection)
throws AbleException
AbleAgent
removeEventConnection in interface AbleAgenttheConnection - The connection to remove.
AbleException - If an error occurs.
The implementor may choose to throw
an exception if the connection does not exist.
public void removeAllEventConnections()
throws AbleException
AbleAgent
removeAllEventConnections in interface AbleAgentAbleException - If an error occurs.
public void setProcessList(java.util.Vector theProcessList)
throws AbleException
AbleAgentA property change event is fired to registered listeners.
setProcessList in interface AbleAgenttheProcessList - The list of beans in the sequence to be processed.
AbleException - If an error occurs.
public java.util.Vector getProcessList()
throws AbleException
AbleAgent
getProcessList in interface AbleAgentAbleException - If an error occurs.
public long getNumEpochs()
throws AbleException
AbleAgent
getNumEpochs in interface AbleAgentAbleException - If an error occurs.
public void removeAllConnections()
throws AbleException
removeAllConnections in interface AbleBeanremoveAllConnections in class AbleObjectAbleException - If an error occurs.AbleObject.removeAllAbleEventListeners(),
AbleObject.removeAllBufferConnections(),
AbleObject.removeAllPropertyConnections()
public void reset()
throws AbleException
In this implementation,
the reset() call is propagated to all DataFlowEnabled
AbleBeans contained within this agent.
The property numEpochs is reset to 0.
reset in interface AbleBeanreset in class AbleObjectAbleException - If an error occurs when resetting
a contained bean. All errors are
collected and insert into the exception
so that one bean's error does not
prevent another from being reset.AbleBean.reset()
public void resetAllBeans()
throws AbleException
resetAllBeans in interface AbleBeanContainerAbleException - If an error occurs.reset(),
AbleBeanContainer.resetAllBeans()
public void initAllBeans()
throws AbleException
initAllBeans in interface AbleBeanContainerAbleException - From the first bean that fails to initialize.
public void init()
throws AbleException
Contained beans are not initialized explicitly
because some agents manage their contained beans directly.
To initialize all contained beans, use initAllBeans().
init in interface AbleBeaninit in class AbleObjectAbleExceptionAbleObject.init()
public void process()
throws AbleException
AbleEvent.DATACHANGED event is propagated
to registered listeners.
In this implementation, a single processing step is performed by walking through the process list and calling the process() method on each DataFlowEnabled AbleBean contained within this agent. If the agent itself is DataFlowEnabled, its inputBuffer is passed to the first bean in the process list, and the outputBuffer from the last bean in the process list populates the agent's outputBuffer.
process in interface AbleBeanprocess in class AbleObjectAbleException - If an error occurs. Errors from each contained
bean are accumulated.AbleObject.inputBuffer,
AbleObject.outputBuffer,
AbleBean.process()public void setDataFlowEnabled(boolean theDataFlowEnabledState)
AbleDataBufferManagerAbleBeanContainer
should recalculate its processing list.
setDataFlowEnabled in interface AbleDataBufferManagersetDataFlowEnabled in class AbleObjecttheDataFlowEnabledState - Indicates if this bean will process
data in buffers. When set to true, this bean
will be included in its parent's process list.
public void quitEnabledEventProcessing()
throws AbleException
AbleState.Unknown.
Timer event processing and ABLE event processing cease, but if event Posting is still enabled, events may still be placed on the internal event queue by other processes.
In this implementation, the quit request is propagated to all AbleBean objects contained within this agent, since it doesn't make sense to quit this object without quitting all the contained objects, too.
quitEnabledEventProcessing in interface AbleEventQueueManagerquitEnabledEventProcessing in class AbleObjectAbleException - If an error occurs. While the quit request is propagated to all beans,
any errors are accumlated so that each bean is quit.AbleObject.startEnabledEventProcessing(),
AbleObject.setAbleEventProcessingEnabled(int),
Able.stopBeanTraceLogging(com.ibm.able.AbleBean)
public void quitAll()
throws AbleException
AbleBeanAbleState.Unknown, and it should
be considered unusable for further processing.
A simple AbleBean may just call
AbleEventQueueManager.quitEnabledEventProcessing().
A more complex bean may also clear itself of references so
that garbage collection can occur.
A bean implementing AbleBeanContainer should call
quitAll on each bean it contains and accumulate errors from each
contained bean.
quitAll in interface AbleBeanquitAll in class AbleObjectAbleException
public void suspendAll()
throws AbleException
AbleBeanAbleState.Suspended.
If the bean is a simple AbleBean, this method just calls its
AbleEventQueueManager.suspendEnabledEventProcessing()
method.
A bean implementing AbleBeanContainer should call
this method on each bean it contains and accumulate errors from
each contained bean.
suspendAll in interface AbleBeansuspendAll in class AbleObjectAbleException
public void resumeAll()
throws AbleException
AbleBeanAbleState.Suspended to
AbleState.Waiting.
If the bean is a simple AbleBean, this method just calls its
AbleEventQueueManager.resumeEnabledEventProcessing()
method.
A bean implementing AbleBeanContainer should call
this method on each bean it contains and accumulate errors from
each contained bean.
resumeAll in interface AbleBeanresumeAll in class AbleObjectAbleException
public void handleAbleEvent(AbleEvent theAbleEvent)
throws AbleException
AbleEvent.EOF,
the numEpochs parameter is incrememented.
In this implementation, special processing occurs for EOF on the active data source. All other events are passed up to the superclass (AbleObject) for processing.
handleAbleEvent in interface AbleEventListenerhandleAbleEvent in class AbleObjecttheAbleEvent - The event to handle.
AbleException - If an error occurs.
public void addBean(AbleBean theAbleBean)
throws AbleException
AbleDataSource, an event connection between the
bean and this agent will be constructed. Only one data source can be
data flow enabled in a container at one time, so if the added bean is an
an active data source, a previously active contained data source will be
made inactive.
processList will be recalculated on its next access or use.
Note that if the bean to be added has a current parent, the bean will be removed from that parent because an ABLE bean can have only one parent at a time. This method will set the specified bean's parent to be this agent.
addBean in interface AbleBeanContainertheAbleBean - The bean to be added to this container.
AbleException - If an error occurs.
public static java.lang.String generateUniqueName(AbleBeanContainer container,
AbleBean bean)
container - The bean container which contains the names in use.bean - The bean to be added to this container.
public void removeBean(AbleBean theAbleBean)
throws AbleException
null.
The following special processing is performed:
processList will be recalculated on its next access or use.
removeBean in interface AbleBeanContainertheAbleBean - A bean that is to be removed from this container.
AbleException - If an error occurs.
public void removeBean(java.lang.String theName)
throws AbleException
removeBean(AbleBean).
removeBean in interface AbleBeanContainertheName - A name of a bean that is to be removed from this container.
AbleException - If an error occurs.
public static void removeBeans(AbleBeanContainer container,
AbleBean[] theBeans)
throws AbleException
removeBean(AbleBean).
container - The container from which beans are to be removed.theBeans - A list of beans to be removed from the container.
AbleException - If an error occurs.
public static void addBeans(AbleBeanContainer container,
AbleBean[] theBeans)
throws AbleException
addBean(AbleBean).
container - The container to which beans are to be added.theBeans - A list of beans to be added to the container.
AbleException - If an error occurs.
public void removeAllBeans()
throws AbleException
AbleBeanContainernull.
removeAllBeans in interface AbleBeanContainerAbleException - If an error occurs.public boolean containsBean(AbleBean theAbleBean)
AbleBeanContainer
containsBean in interface AbleBeanContainertheAbleBean - A bean that to find in this container.
public boolean containsBean(java.lang.String theName)
AbleBeanContainer
containsBean in interface AbleBeanContainertheName - The specific name of a bean to find in this container.
public AbleBean getBean(java.lang.String theName)
AbleBeanContainer
getBean in interface AbleBeanContainertheName - The specific name of a bean to be returned.
public java.util.Vector getBeans()
AbleBeanContainer
getBeans in interface AbleBeanContainerpublic void addUserDefinedFunction(AbleUserDefinedFunction theUserDefinedFunction)
AbleUserDefinedFunctionManager
addUserDefinedFunction in interface AbleUserDefinedFunctionManagertheUserDefinedFunction - The user-defined function to be added to the master
list.
public void removeUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
int theArity)
AbleUserDefinedFunctionManager
removeUserDefinedFunction in interface AbleUserDefinedFunctionManagertheUserDefinedFunctionName - The name of the user-defined function to be removed
from the master list.theArity - The number of arguments expected by the named
function.
public boolean containsUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
int theArity)
AbleUserDefinedFunctionManager
containsUserDefinedFunction in interface AbleUserDefinedFunctionManagertheUserDefinedFunctionName - The name of a user-defined function that might be in
the master list.theArity - The number of arguments expected by the named
function.
public AbleUserDefinedFunction getUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
int theArity)
AbleUserDefinedFunctionManager
getUserDefinedFunction in interface AbleUserDefinedFunctionManagertheUserDefinedFunctionName - The name of a user-defined function that might be in
the master list.
theArity - The number of arguments expected by the named
function.
public java.lang.Object invokeUserDefinedFunction(java.lang.String theUserDefinedFunctionName,
java.lang.Object[] theArgs)
throws AbleException,
java.lang.NoSuchMethodException,
java.lang.reflect.InvocationTargetException,
java.lang.IllegalAccessException,
java.lang.SecurityException
AbleUserDefinedFunctionManager
invokeUserDefinedFunction in interface AbleUserDefinedFunctionManagertheUserDefinedFunctionName - The name of the user-defined function containing an
encapsulated method.
theArgs - An array of arguments expected by the encapsulated
method.
AbleException - If any other error occurs.
java.lang.IllegalAccessException - If the method is not public or otherwise accessible.
java.lang.reflect.InvocationTargetException - If an exception was thrown by the invoked method.
java.lang.NoSuchMethodException - If the method or method signature is not defined in the
encapsulated source object.
java.lang.SecurityException - If the invoker lacks authority to invoke the method.public void setUserDefinedFunctions(java.util.Hashtable theUserDefinedFunctions)
AbleUserDefinedFunctionManager
setUserDefinedFunctions in interface AbleUserDefinedFunctionManagertheUserDefinedFunctions - A list of AbleUserDefinedFunction objects. This list
completely replaces the current list. The input list
is cloned.public java.util.Hashtable getUserDefinedFunctions()
AbleUserDefinedFunctionManager
getUserDefinedFunctions in interface AbleUserDefinedFunctionManagerpublic void propertyChange(java.beans.PropertyChangeEvent theEvent)
AbleProperty.DataFlowEnabled event, which occurs when data flow is enabled,
causes any other AbleDataSource objects contained to set dataflow off, and
will cause the process list to be reconstructed on its next use or access.
AbleProperty.Name event, which occurs when a bean name is changed,
will cause this parent to update its list of contained beans which uses the name as
the key. If the new name is not unique, a unique name is generated.
AbleProperty.SourceBufferConnections event, which occurs a buffer connection is
added or deleted, will cause the process list to be reconstructed on its next use or access.
propertyChange in interface java.beans.PropertyChangeListenertheEvent - The property change event.
protected void buildProcessList()
throws AbleException
myBeans for dataflow
connections, building a sequential processing list.
Lists all datasource objects first starting with the one
enabled for data flow, then all data buffer-connected objects in sequence,
regardless of if they are on or off.
AbleException - If an error occurs.protected void debugTrace(java.lang.String theMessage)
Able.TRC_LOW
if Able.Debug is enabled. Take no action if
disabled.
theMessage - A String containing text to be traced.protected java.lang.String clsNm()
|
ABLE 2.3.0 07/13/2005 14:21:00 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||