atg.service.event
Class EventHandlerRegistry

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.GenericContext
              extended by atg.service.event.EventHandlerRegistry
All Implemented Interfaces:
NameContext, NameContextBindingEventSource, NameContextBindingListener, NameContextElement, atg.naming.NameContextPreBindingEventSource, NameResolver, AdminableService, atg.nucleus.ConfigurationListener, atg.nucleus.ConfigurationLockRegistry, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener, javax.servlet.ServletContext

public class EventHandlerRegistry
extends GenericContext
implements java.util.EventListener, atg.nucleus.ConfigurationListener

Central mechanism by which handlers are registered to listen to specific event channels.

The handlerPath property of the registry defines the location of properties files for handlers. The registry looks through that directory for components who extend the GenericHandler class. The registry starts these components and registers them with the event distributor to listen for events on their specified default channels.

The registry is also notified of when a components configuration is deleted or updated and should act accordingly.

Since a handler need only implement the EventChannelListener interface and not extend GenericHandler, the registry also allows other components to register themselves by calling the registerHandler() and unregisterHandler() methods.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected static java.lang.Class mBaseHandlerClass
          The base class for all registered handlers must be GenericHandler.
protected  atg.service.event.EventDistributor mDistributor
          The event distributor.
protected  java.lang.String mHandlerPath
          The Nucleus (or property path) where handlers are configured.
 
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
EventHandlerRegistry()
          Empty constructor.
 
Method Summary
 void configurationDeleted(atg.nucleus.ConfigurationEvent e)
          Called whenever a Nucleus component's configuration is deleted.
 void configurationUpdated(atg.nucleus.ConfigurationEvent e)
          Called whenever a Nucleus component's configuration is updated.
 void doStartService()
          Perform any necessary initializations to startup service.
 EventChannelListener[] getActiveHandlers()
          Returns an array of the currently registered Handlers.
 EventChannelListener[] getChannelListeners(java.lang.String pChannelString)
          Returns any handlers registered to listen to the given channel.
 java.lang.String[] getChannelsForHandler(EventChannelListener pHandler)
          Returns a String array of the event channels currently being listened to by the specified handler.
 java.lang.String[] getChannelsForHandler(java.lang.String pHandlerName)
          Returns a String array of the event channels currently being listened to by the specified handler.
 java.lang.String[] getChannelSubTopics(java.lang.String pChannelString)
          Returns any sub-topics of the give channel.
 atg.service.event.EventDistributor getDistributor()
          The event distributor.
 int getHandlerCount()
          The number of unique registered handlers.
 java.lang.String getHandlerPath()
          The Nucleus (or property path) where handlers are configured.
 void refresh()
          Refreshes the list of active handlers, starts any handlers not already started and registers them with the distributor on thier specified default channels.
 void registerHandler(java.lang.String pChannel, EventChannelListener pHandler)
          Registers an EventChannelListener to listen to events on the specified event channel.
 void setDistributor(atg.service.event.EventDistributor pValue)
          The event distributor.
 void setHandlerPath(java.lang.String pValue)
          The Nucleus (or property path) where handlers are configured.
 void unregisterHandler(java.lang.String pChannel, EventChannelListener pHandler)
          Unregisters an EventChannelListener from listening to events on the specified event channel.
 
Methods inherited from class atg.nucleus.GenericContext
addNameContextBindingListener, addNameContextPreBindingListener, clearElementLock, doStopService, getAttribute, getAttributeNames, getConfigurationLock, getContext, getDocumentRoot, getElement, getElementLock, getInitParameter, getInitParameterNames, getMajorVersion, getMimeType, getMimeTyper, getMinorVersion, getNameContextBindingListeners, getNameContextPreBindingListeners, getNamedDispatcher, getPendingElement, getRealPath, getRequestDispatcher, getResource, getResourceAsStream, getResourcePaths, getServerInfo, getServlet, getServletContextName, getServletNames, getServlets, isElementBound, listElement, listElementNames, listElements, log, log, log, notifyAddedObject, notifyRemovedObject, preNotifyAddedObject, preNotifyRemovedObject, putElement, putPendingElement, removeAttribute, removeElement, removeNameContextBindingListener, removeNameContextPreBindingListener, removePendingElement, setAttribute, setDocumentRoot, setMimeTyper, startService
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, 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, 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
 
Methods inherited from interface atg.naming.NameContextElement
getName, getNameContext
 
Methods inherited from interface atg.naming.NameContextBindingListener
nameContextElementBound, nameContextElementUnbound
 
Methods inherited from interface atg.naming.NameContextElement
getName, getNameContext
 
Methods inherited from interface atg.naming.NameContextBindingListener
nameContextElementBound, nameContextElementUnbound
 
Methods inherited from interface atg.naming.NameContextElement
getName, getNameContext
 
Methods inherited from interface atg.naming.NameContextBindingListener
nameContextElementBound, nameContextElementUnbound
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


mBaseHandlerClass

protected static final java.lang.Class mBaseHandlerClass
The base class for all registered handlers must be GenericHandler.


mDistributor

protected atg.service.event.EventDistributor mDistributor
The event distributor.


mHandlerPath

protected java.lang.String mHandlerPath
The Nucleus (or property path) where handlers are configured.

Constructor Detail

EventHandlerRegistry

public EventHandlerRegistry()
Empty constructor.

Method Detail

setDistributor

public void setDistributor(atg.service.event.EventDistributor pValue)
The event distributor.


getDistributor

public atg.service.event.EventDistributor getDistributor()
The event distributor.


setHandlerPath

public void setHandlerPath(java.lang.String pValue)
The Nucleus (or property path) where handlers are configured. Default value is this components nucelus path plus "/handlers/".


getHandlerPath

public java.lang.String getHandlerPath()
The Nucleus (or property path) where handlers are configured. Default value is this components nucelus path plus "/handlers/".


getHandlerCount

public int getHandlerCount()
The number of unique registered handlers.


getActiveHandlers

public EventChannelListener[] getActiveHandlers()
Returns an array of the currently registered Handlers.


doStartService

public void doStartService()
                    throws ServiceException
Perform any necessary initializations to startup service.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

refresh

public void refresh()
Refreshes the list of active handlers, starts any handlers not already started and registers them with the distributor on thier specified default channels.

Note that these handlers must extend GenericHandler, otherwise they will not be started or registered. To register handlers that do not extend GenericHandler, see the registerHandler() and unregisterHandler() methods.


registerHandler

public void registerHandler(java.lang.String pChannel,
                            EventChannelListener pHandler)
                     throws EventException
Registers an EventChannelListener to listen to events on the specified event channel. Note that calling this method will not create a properties file in the registered handler directory for the supplied handler, i.e. the registry will not auto-register the handler the next time Dynamo starts.

Throws:
EventException

unregisterHandler

public void unregisterHandler(java.lang.String pChannel,
                              EventChannelListener pHandler)
Unregisters an EventChannelListener from listening to events on the specified event channel. Note that calling this method will not remove any properties files from the registered handler directory for the supplied handler.


getChannelsForHandler

public java.lang.String[] getChannelsForHandler(EventChannelListener pHandler)
Returns a String array of the event channels currently being listened to by the specified handler. Returns null if the handler is listening to no channels.


getChannelsForHandler

public java.lang.String[] getChannelsForHandler(java.lang.String pHandlerName)
Returns a String array of the event channels currently being listened to by the specified handler. Returns null if the handler is listening to no channels.


getChannelSubTopics

public java.lang.String[] getChannelSubTopics(java.lang.String pChannelString)
Returns any sub-topics of the give channel. Note that the topics are returned as complete channel strings.


getChannelListeners

public EventChannelListener[] getChannelListeners(java.lang.String pChannelString)
Returns any handlers registered to listen to the given channel. If there are no handlers, null is returned.


configurationDeleted

public void configurationDeleted(atg.nucleus.ConfigurationEvent e)
Called whenever a Nucleus component's configuration is deleted. We check to see if it is one of our handlers and refresh accordingly.

Specified by:
configurationDeleted in interface atg.nucleus.ConfigurationListener

configurationUpdated

public void configurationUpdated(atg.nucleus.ConfigurationEvent e)
Called whenever a Nucleus component's configuration is updated. We check to see if it is one of our handlers and refresh accordingly.

Specified by:
configurationUpdated in interface atg.nucleus.ConfigurationListener