8.3.3 Observation Manager

The ObservationManager interface supports listener registration and deregistration.

javax.jcr.observation.
ObservationManager

void

addEventListener(EventListener listener,
int eventTypes,
String absPath,
boolean isDeep,
String[] uuid,
String[] nodeTypeName,
boolean noLocal)

Adds an event listener that listens for the specified eventTypes (a combination of one or more event types encoded as a bit mask value).

The set of events can be filtered by specifying restrictions based on characteristics of the associated parent node of the event. The associated parent node of an event is the parent node of the item at (or formerly at) the path returned by Event.getPath. The following restrictions are available:

  • absPath, isDeep: Only events whose associated parent node is at absPath (or within its subtree, if isDeep is true) will be received. It is permissible to register a listener for a path where no node currently exists.

  • uuid: Only events whose associated parent node has one of the UUIDs in this list will be received. If this parameter is null then no UUID-related restriction is placed on events received. Note that specifying an empty array instead of null would result in no nodes being listened to.

  • nodeTypeName: Only events whose associated parent node has one of the node types (or a subtype of one of the node types) in this list will be received. If this parameter is null then no node type-related restriction is placed on events received. Note that specifying an empty array instead of null would result in no node types being listened to.

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 EventListener can be changed at runtime by re-registering the same EventListener object (i.e. the same actual Java object) with a new set of filter arguments. The implementation must ensure that no events are lost during the changeover.

A RepositoryException is thrown if an error occurs.

void

removeEventListener(EventListener listener)

Deregisters an event listener.

A RepositoryException is thrown if an error occurs.

EventListenerIterator

getRegisteredEventListeners()

Returns all event listeners that have been registered through this session. If no listeners have been registered, an empty iterator is returned.

A RepositoryException is thrown if an error occurs.