In addition to JCR observation, Jackrabbit support cluster-aware event processing and synchronous observation listeners.

Cluster-Aware Event Processing

Sometimes events must only be processed by the cluster node where the event originated, or only by cluster nodes where the event didn't originate. Each event contains an 'external' flag that indicated whether the event originated on another cluster node, that means whether the code that manipulated the node ran in another cluster node. Example source code:

import org.apache.jackrabbit.api.observation.JackrabbitEvent;
public void onEvent(EventIterator events) {
    while (events.hasNext()) {
    Event e = events.nextEvent();
    if (e instanceof JackrabbitEvent && ((JackrabbitEvent) e).isExternal()) {
        // event originated in another cluster node
    } else {
        // event originated in this cluster node
    }
}

Synchronous Observation Listener

By default Jackrabbit call observation listeners some time after the event occurs. However, synchronous observation is supported as well. To use it, the observation listener needs to implement the interface org.apache.jackrabbit.core.observation.SynchronousEventListener. Please note that this interface is _not_ part of the Jackrabbit API, and should only be used if really required.

A synchronous event listener should never write to the repository using the same session that was used to create it.

Observation (last edited 2009-09-23 11:48:30 by ThomasMueller)