atg.service.event
Class ConfigurableActionHandler

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.event.GenericHandler
              extended by atg.service.event.ConfigurableActionHandler
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, EventChannelListener, java.util.EventListener

public class ConfigurableActionHandler
extends GenericHandler

This handler takes an array of ConfigurableActions as a property. As each event comes into the handler, the actions are performed on the event. With the proper setup, actions can be queued for later execution. Setting the 'queueActions' property to true will will put each incoming event into a QueuedAction along with the ConfigurableActions of this handler. These QueuedActions are then passed to the QueuedActionQueue set as the 'queue' property of this handler. The QueuedActionQueue later passes each QueuedAction to a single listener of the queue, a QueuedActionHandler. The QueuedActionHandler pulls out the actions and performs them on the original event.

A simple filtering of incoming events is done inside the doesEventQualify() method. Each incoming event is compared to the eventClass and eventType (if the event extends GenericEvent) properties. If they match up, the event is handled. If not, the event is ignored. The doesEventQualify() method can be overridden to follow a different policy.

See Also:
GenericEvent, ConfigurableAction, QueuedActionQueue, QueuedActionHandler

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.service.event.GenericHandler
mChannels, mEventCount
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ConfigurableActionHandler()
          Empty constructor.
 
Method Summary
protected  void doActions(java.lang.Object pEvent)
          Peforms the configured actions on the event now.
 boolean doesEventQualify(java.lang.Object pEvent)
          Checks to see if the incoming object qualifies to be handled.
 atg.service.event.QueuedActionListener getActionQueue()
          The event queue to pass actions into.
 atg.service.event.ConfigurableAction[] getActions()
          The set of actions to perform on an event.
 java.lang.Class getEventClass()
          The event class that this handler should listen for.
 int getEventType()
          The type of the event class that this handler should listen for.
 boolean getQueueActions()
          Whether or not to queue event actions or do them immediately.
protected  void queueActions(java.lang.Object pEvent)
          Queues the configured actions to be performed later.
 void sendEvent(java.lang.Object pEvent)
          Submits an event for handling.
 void setActionQueue(atg.service.event.QueuedActionListener pValue)
          The event queue to pass actions into.
 void setActions(atg.service.event.ConfigurableAction[] pValue)
          The set of actions to perform on an event.
 void setEventClass(java.lang.Class pValue)
          The event class that this handler should listen for.
 void setEventType(int pValue)
          The type of the event class that this handler should listen for.
 void setQueueActions(boolean pValue)
          Whether or not to queue event actions or do them immediately.
 
Methods inherited from class atg.service.event.GenericHandler
getChannels, getEventCount, getHandlerName, isRegisterAtStartup, setChannels, setRegisterAtStartup
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

ConfigurableActionHandler

public ConfigurableActionHandler()
Empty constructor.

Method Detail

setQueueActions

public void setQueueActions(boolean pValue)
Whether or not to queue event actions or do them immediately.


getQueueActions

public boolean getQueueActions()
Whether or not to queue event actions or do them immediately.


setActionQueue

public void setActionQueue(atg.service.event.QueuedActionListener pValue)
The event queue to pass actions into.


getActionQueue

public atg.service.event.QueuedActionListener getActionQueue()
The event queue to pass actions into.


setActions

public void setActions(atg.service.event.ConfigurableAction[] pValue)
The set of actions to perform on an event.


getActions

public atg.service.event.ConfigurableAction[] getActions()
The set of actions to perform on an event.


setEventClass

public void setEventClass(java.lang.Class pValue)
The event class that this handler should listen for.


getEventClass

public java.lang.Class getEventClass()
The event class that this handler should listen for.


setEventType

public void setEventType(int pValue)
The type of the event class that this handler should listen for.


getEventType

public int getEventType()
The type of the event class that this handler should listen for.


doesEventQualify

public boolean doesEventQualify(java.lang.Object pEvent)
Checks to see if the incoming object qualifies to be handled.

Currently, this class only takes in one event class and one event class type to qualify for handling. Properties can be added and this method can be overloaded so that an array of Classes and respective types can be be accepted for handling. That is left as an exercise for the reader.

Parameters:
pEvent - the event to check.
Returns:
boolean whether or not the event qualifies to be handled.

sendEvent

public void sendEvent(java.lang.Object pEvent)
Submits an event for handling.

Specified by:
sendEvent in interface EventChannelListener
Overrides:
sendEvent in class GenericHandler
Parameters:
pEvent - the event to send for handling.

doActions

protected void doActions(java.lang.Object pEvent)
Peforms the configured actions on the event now.


queueActions

protected void queueActions(java.lang.Object pEvent)
Queues the configured actions to be performed later.