use of org.apache.jackrabbit.jcr2spi.observation.InternalEventListener in project jackrabbit by apache.
the class WorkspaceManager method onEventReceived.
//--------------------------------------------------------------------------
/**
* Called when local or external events occurred. This method is called after
* changes have been applied to the repository.
*
* @param eventBundles the event bundles generated by the repository service
* as the effect of an local or external change.
* @param lstnrs Array of internal event listeners
* @throws InterruptedException if this thread is interrupted while waiting
* for the {@link #updateSync}.
*/
private void onEventReceived(EventBundle[] eventBundles, InternalEventListener[] lstnrs) throws InterruptedException {
if (log.isDebugEnabled()) {
log.debug("received {} event bundles.", eventBundles.length);
for (EventBundle eventBundle : eventBundles) {
log.debug("IsLocal: {}", eventBundle.isLocal());
for (Iterator<Event> it = eventBundle.getEvents(); it.hasNext(); ) {
Event e = it.next();
String type;
switch(e.getType()) {
case Event.NODE_ADDED:
type = "NodeAdded";
break;
case Event.NODE_REMOVED:
type = "NodeRemoved";
break;
case Event.PROPERTY_ADDED:
type = "PropertyAdded";
break;
case Event.PROPERTY_CHANGED:
type = "PropertyChanged";
break;
case Event.PROPERTY_REMOVED:
type = "PropertyRemoved";
break;
case Event.NODE_MOVED:
type = "NodeMoved";
break;
case Event.PERSIST:
type = "Persist";
break;
default:
type = "Unknown";
}
log.debug(" {}; {}", e.getPath(), type);
}
}
}
// do not deliver events while an operation executes
updateSync.acquire();
try {
// notify listener
for (EventBundle eventBundle : eventBundles) {
for (InternalEventListener lstnr : lstnrs) {
try {
lstnr.onEvent(eventBundle);
} catch (Exception e) {
log.warn("Exception in event polling thread: " + e);
log.debug("Dump:", e);
}
}
}
} finally {
updateSync.release();
}
}
Aggregations