com.continuent.tungsten.replicator.util
Class WatchManager<E>

java.lang.Object
  extended by com.continuent.tungsten.replicator.util.WatchManager<E>

public class WatchManager<E>
extends java.lang.Object

Manages a list of event watches and allows clients to submit events to the list for processing to see if there is a predicate match. Methods are synchronized to ensure the object is updated transactionally and to ensure proper visibility across threads.

Author:
Robert Hodges

Constructor Summary
WatchManager()
           
 
Method Summary
 void cancelAll()
          Cancel all pending watches.
 java.util.List<Watch<E>> getWatches()
          Returns the current list of watches.
 void process(E event, int taskId)
          Submits an event for watch processing.
 Watch<E> watch(WatchPredicate<E> predicate, int taskCount)
          Adds a new watch predicate to the queue.
 Watch<E> watch(WatchPredicate<E> predicate, int taskCount, WatchAction<E> action)
          Adds a new watch predicate to the queue including an accompanying action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WatchManager

public WatchManager()
Method Detail

watch

public Watch<E> watch(WatchPredicate<E> predicate,
                      int taskCount,
                      WatchAction<E> action)
Adds a new watch predicate to the queue including an accompanying action.


watch

public Watch<E> watch(WatchPredicate<E> predicate,
                      int taskCount)
Adds a new watch predicate to the queue.


getWatches

public java.util.List<Watch<E>> getWatches()
Returns the current list of watches.


process

public void process(E event,
                    int taskId)
             throws java.lang.InterruptedException
Submits an event for watch processing. This automatically dequeues any matching watch instances and informs the watchers.

Parameters:
event - An event for processing.
taskId - Id of task for which we are checking the predicate
Throws:
java.lang.InterruptedException

cancelAll

public void cancelAll()
Cancel all pending watches.