info.magnolia.cms.util
Class ObservationUtil

java.lang.Object
  extended by info.magnolia.cms.util.ObservationUtil

public class ObservationUtil
extends Object

Util to register JCR observations. Supports delayed execution of the listener to handle event bursts.

Version:
$Id: ObservationUtil.java 56279 2012-03-28 07:58:23Z ehechinger $

Nested Class Summary
static class ObservationUtil.DeferringEventListener
          A listener using an ObservationUtil.ObservationBasedDelayedExecutor.
static class ObservationUtil.ListBasedEventIterator
          List based event iterator.
static class ObservationUtil.ObservationBasedDelayedExecutor
          Deferred event handling.
 
Constructor Summary
ObservationUtil()
           
 
Method Summary
static void dispose(String workspace)
          Unregisters all EventListeners for the given workspace.
static javax.jcr.observation.EventListener instanciateDeferredEventListener(javax.jcr.observation.EventListener listener, long delay, long maxDelay)
          Use this and register the returned EventListener with the registerChangeListener() methods, if you need to be able to later unregister your EventListener.
static void registerChangeListener(String workspace, String observationPath, boolean includeSubnodes, javax.jcr.observation.EventListener listener)
          Registers an EventListener for any node type.
static void registerChangeListener(String workspace, String observationPath, boolean includeSubnodes, String[] nodeTypes, javax.jcr.observation.EventListener listener)
          Registers an EventListener for a specific set of node types and event types.
static void registerChangeListener(String workspace, String observationPath, boolean includeSubnodes, String[] nodeTypes, int eventTypesMask, javax.jcr.observation.EventListener listener)
          Register a single event listener, bound to the given path.
static void registerChangeListener(String workspace, String observationPath, boolean includeSubnodes, String nodeType, javax.jcr.observation.EventListener listener)
          Registers an EventListener for a specific node type.
static void registerChangeListener(String workspace, String observationPath, boolean includeSubnodes, String nodeType, int eventTypesMask, javax.jcr.observation.EventListener listener)
          Registers an EventListener for a specific node type and event types.
static void registerChangeListener(String workspace, String observationPath, javax.jcr.observation.EventListener listener)
          Registers an EventListener for any node type.
static void registerDeferredChangeListener(String workspace, String observationPath, boolean includeSubnodes, javax.jcr.observation.EventListener listener, long delay, long maxDelay)
           
static void registerDeferredChangeListener(String workspace, String observationPath, boolean includeSubnodes, String[] nodeTypes, javax.jcr.observation.EventListener listener, long delay, long maxDelay)
          The event firing is deferred in case there is a series of fired events.
static void registerDeferredChangeListener(String workspace, String observationPath, boolean includeSubnodes, String nodeType, javax.jcr.observation.EventListener listener, long delay, long maxDelay)
           
static void registerDeferredChangeListener(String workspace, String observationPath, javax.jcr.observation.EventListener listener, long delay, long maxDelay)
           
static void unregisterChangeListener(String workspace, javax.jcr.observation.EventListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObservationUtil

public ObservationUtil()
Method Detail

dispose

public static void dispose(String workspace)
Unregisters all EventListeners for the given workspace.


registerChangeListener

public static void registerChangeListener(String workspace,
                                          String observationPath,
                                          javax.jcr.observation.EventListener listener)
Registers an EventListener for any node type.

See Also:
registerChangeListener(String,String,boolean,String[],javax.jcr.observation.EventListener)

registerChangeListener

public static void registerChangeListener(String workspace,
                                          String observationPath,
                                          boolean includeSubnodes,
                                          javax.jcr.observation.EventListener listener)
Registers an EventListener for any node type.

See Also:
registerChangeListener(String,String,boolean,String[],javax.jcr.observation.EventListener)

registerChangeListener

public static void registerChangeListener(String workspace,
                                          String observationPath,
                                          boolean includeSubnodes,
                                          String nodeType,
                                          javax.jcr.observation.EventListener listener)
Registers an EventListener for a specific node type.

See Also:
registerChangeListener(String,String,boolean,String[],javax.jcr.observation.EventListener)

registerChangeListener

public static void registerChangeListener(String workspace,
                                          String observationPath,
                                          boolean includeSubnodes,
                                          String nodeType,
                                          int eventTypesMask,
                                          javax.jcr.observation.EventListener listener)
Registers an EventListener for a specific node type and event types.

See Also:
registerChangeListener(String,String,boolean,String[],int,javax.jcr.observation.EventListener)

registerChangeListener

public static void registerChangeListener(String workspace,
                                          String observationPath,
                                          boolean includeSubnodes,
                                          String[] nodeTypes,
                                          javax.jcr.observation.EventListener listener)
Registers an EventListener for a specific set of node types and event types.

See Also:
registerChangeListener(String, String, boolean, String[], int, javax.jcr.observation.EventListener)

registerChangeListener

public static void registerChangeListener(String workspace,
                                          String observationPath,
                                          boolean includeSubnodes,
                                          String[] nodeTypes,
                                          int eventTypesMask,
                                          javax.jcr.observation.EventListener listener)
Register a single event listener, bound to the given path. Be careful that if you observe "/", events are going to be generated for jcr:system, which is "shared" across all workspaces.

Parameters:
workspace -
observationPath - workspace path
includeSubnodes - the isDeep parameter of ObservationManager.addEventListener()
nodeTypes - the node types to filter events for
eventTypesMask - an ORed mask of even types (Event constants)
listener - event listener
See Also:
ObservationManager.addEventListener(javax.jcr.observation.EventListener, int, java.lang.String, boolean, java.lang.String[], java.lang.String[], boolean), Event

registerDeferredChangeListener

public static void registerDeferredChangeListener(String workspace,
                                                  String observationPath,
                                                  javax.jcr.observation.EventListener listener,
                                                  long delay,
                                                  long maxDelay)

registerDeferredChangeListener

public static void registerDeferredChangeListener(String workspace,
                                                  String observationPath,
                                                  boolean includeSubnodes,
                                                  javax.jcr.observation.EventListener listener,
                                                  long delay,
                                                  long maxDelay)

registerDeferredChangeListener

public static void registerDeferredChangeListener(String workspace,
                                                  String observationPath,
                                                  boolean includeSubnodes,
                                                  String nodeType,
                                                  javax.jcr.observation.EventListener listener,
                                                  long delay,
                                                  long maxDelay)

registerDeferredChangeListener

public static void registerDeferredChangeListener(String workspace,
                                                  String observationPath,
                                                  boolean includeSubnodes,
                                                  String[] nodeTypes,
                                                  javax.jcr.observation.EventListener listener,
                                                  long delay,
                                                  long maxDelay)
The event firing is deferred in case there is a series of fired events.


instanciateDeferredEventListener

public static javax.jcr.observation.EventListener instanciateDeferredEventListener(javax.jcr.observation.EventListener listener,
                                                                                   long delay,
                                                                                   long maxDelay)
Use this and register the returned EventListener with the registerChangeListener() methods, if you need to be able to later unregister your EventListener.


unregisterChangeListener

public static void unregisterChangeListener(String workspace,
                                            javax.jcr.observation.EventListener listener)


Copyright © 2003-2012 Magnolia International Ltd.. All Rights Reserved.