org.jboss.dna.repository.observation
Class ObservationService

java.lang.Object
  extended by org.jboss.dna.repository.observation.ObservationService
All Implemented Interfaces:
AdministeredService

public class ObservationService
extends Object
implements AdministeredService

Author:
Randall Hauch

Nested Class Summary
 class ObservationService.DefaultProblemLog
          Problem log implementation that records problems in the log.
static interface ObservationService.ProblemLog
          Interface to which problems with particular events are logged.
 class ObservationService.Statistics
          The statistics for the system.
 class ObservationService.WorkspaceListener
          Implementation of the JCR EventListener interface, returned by the sequencing system.
 
Field Summary
static ObservationService.ProblemLog NO_OP_PROBLEM_LOG
           
 
Constructor Summary
ObservationService(SessionFactory sessionFactory)
           
 
Method Summary
 boolean addListener(javax.jcr.observation.EventListener listener)
           
 boolean addListener(NodeChangeListener listener)
           
 ServiceAdministrator getAdministrator()
          
 Logger getLogger()
          Get the logger for this system
 ObservationService.ProblemLog getProblemLog()
           
 SessionFactory getSessionFactory()
           
 ObservationService.Statistics getStatistics()
          Get the statistics for this system.
 ObservationService.WorkspaceListener monitor(String repositoryWorkspaceName, int eventTypes, String... nodeTypeNames)
          Monitor the supplied workspace for the supplied event types on any node in the workspace.
 ObservationService.WorkspaceListener monitor(String repositoryWorkspaceName, String absolutePath, int eventTypes, boolean isDeep, String[] uuids, String[] nodeTypeNames, boolean noLocal)
          Monitor the supplied workspace for events of the given type on any node at or under the supplied path.
 ObservationService.WorkspaceListener monitor(String repositoryWorkspaceName, String absolutePath, String... nodeTypeNames)
          Monitor the supplied workspace for default event types on any node at or under the supplied path.
 boolean removeListener(javax.jcr.observation.EventListener listener)
           
 boolean removeListener(NodeChangeListener listener)
           
 void setLogger(Logger logger)
          Set the logger for this system.
 void setProblemLog(ObservationService.ProblemLog problemLog)
          Set the problem log that will be notified of problems handling events.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_OP_PROBLEM_LOG

public static final ObservationService.ProblemLog NO_OP_PROBLEM_LOG
Constructor Detail

ObservationService

public ObservationService(SessionFactory sessionFactory)
Method Detail

getAdministrator

public ServiceAdministrator getAdministrator()

Specified by:
getAdministrator in interface AdministeredService

getSessionFactory

public SessionFactory getSessionFactory()
Returns:
sessionFactory

getStatistics

public ObservationService.Statistics getStatistics()
Get the statistics for this system.

Returns:
the statistics, which are updated as the system is used

getLogger

public Logger getLogger()
Get the logger for this system

Returns:
the logger

setLogger

public void setLogger(Logger logger)
Set the logger for this system.

Parameters:
logger - the logger, or null if the standard logging should be used

getProblemLog

public ObservationService.ProblemLog getProblemLog()
Returns:
problemLog

setProblemLog

public void setProblemLog(ObservationService.ProblemLog problemLog)
Set the problem log that will be notified of problems handling events. By default, such problems are sent to the log.

Parameters:
problemLog - the new problem log implementation; if null, then the default problem log is used

addListener

public boolean addListener(javax.jcr.observation.EventListener listener)

removeListener

public boolean removeListener(javax.jcr.observation.EventListener listener)

addListener

public boolean addListener(NodeChangeListener listener)

removeListener

public boolean removeListener(NodeChangeListener listener)

monitor

public ObservationService.WorkspaceListener monitor(String repositoryWorkspaceName,
                                                    String absolutePath,
                                                    int eventTypes,
                                                    boolean isDeep,
                                                    String[] uuids,
                                                    String[] nodeTypeNames,
                                                    boolean noLocal)
                                             throws javax.jcr.RepositoryException
Monitor the supplied workspace for events of the given type on any node at or under the supplied path.

Monitoring is accomplished by registering a listener on the workspace, so this monitoring only has access to the information that visible to the session created by the session factory for the given repository and workspace name.

The listener returned from this method is not managed by this SequencingService instance. If the listener is no longer needed, it simply must be removed as a listener of the workspace and garbage collected. If this service is shutdown while there are still active listeners, those listeners will disconnect themselves from this service and the workspace with which they're registered when they attempt to forward the next events.

The set of events that are monitored can be filtered by specifying restrictions based on characteristics of the node associated with the event. In the case of event types NODE_ADDED and NODE_REMOVED, the node associated with an event is the node at (or formerly at) the path returned by Event.getPath(). In the case of event types PROPERTY_ADDED, PROPERTY_REMOVED and PROPERTY_CHANGED, the node associated with an event is the parent node of the property at (or formerly at) the path returned by Event.getPath:

The restrictions are "ANDed" together. In other words, for a particular node to be "listened to" it must meet all the restrictions.

Additionally, if noLocal is true, then events generated by the session through which the listener was registered are ignored. Otherwise, they are not ignored.

The filters of an already-registered ObservationService.WorkspaceListener can be changed at runtime by changing the attributes and registering.

Parameters:
repositoryWorkspaceName - the name to be used with the session factory to obtain a session to the repository and workspace that is to be monitored
absolutePath - the absolute path of the node at or below which changes are to be monitored; may be null if all nodes in the workspace are to be monitored
eventTypes - the bitmask of the Event types that are to be monitored
isDeep - true if events below the node given by the absolutePath or by the uuids are to be processed, or false if only the events at the node
uuids - array of UUIDs of nodes that are to be monitored; may be null or empty if the UUIDs are not known
nodeTypeNames - array of node type names that are to be monitored; may be null or empty if the monitoring has no node type restrictions
noLocal - true if the events originating in the supplied workspace are to be ignored, or false if they are also to be processed.
Returns:
the listener that was created and registered to perform the monitoring
Throws:
javax.jcr.RepositoryException - if there is a problem registering the listener

monitor

public ObservationService.WorkspaceListener monitor(String repositoryWorkspaceName,
                                                    String absolutePath,
                                                    String... nodeTypeNames)
                                             throws javax.jcr.RepositoryException
Monitor the supplied workspace for default event types on any node at or under the supplied path.

Monitoring is accomplished by registering a listener on the workspace, so this monitoring only has access to the information that visible to the session created by the session factory for the given repository and workspace name.

The listener returned from this method is not managed by this SequencingService instance. If the listener is no longer needed, it simply must be removed as a listener of the workspace and garbage collected.

Parameters:
repositoryWorkspaceName - the name to be used with the session factory to obtain a session to the repository and workspace that is to be monitored
absolutePath - the absolute path of the node at or below which changes are to be monitored; may be null if all nodes in the workspace are to be monitored
nodeTypeNames - the names of the node types that are to be monitored; may be null or empty if the monitoring has no node type restrictions
Returns:
the listener that was created and registered to perform the monitoring
Throws:
javax.jcr.RepositoryException - if there is a problem registering the listener

monitor

public ObservationService.WorkspaceListener monitor(String repositoryWorkspaceName,
                                                    int eventTypes,
                                                    String... nodeTypeNames)
                                             throws javax.jcr.RepositoryException
Monitor the supplied workspace for the supplied event types on any node in the workspace.

Monitoring is accomplished by registering a listener on the workspace, so this monitoring only has access to the information that visible to the session created by the session factory for the given repository and workspace name.

The listener returned from this method is not managed by this SequencingService instance. If the listener is no longer needed, it simply must be removed as a listener of the workspace and garbage collected.

Parameters:
repositoryWorkspaceName - the name to be used with the session factory to obtain a session to the repository and workspace that is to be monitored
eventTypes - the bitmask of the Event types that are to be monitored
nodeTypeNames - the names of the node types that are to be monitored; may be null or empty if the monitoring has no node type restrictions
Returns:
the listener that was created and registered to perform the monitoring
Throws:
javax.jcr.RepositoryException - if there is a problem registering the listener


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.