com.graemestevenson.notifier
Class NonBlockingNotifier<T>

java.lang.Object
  extended by com.graemestevenson.notifier.AbstractNotifier<T>
      extended by com.graemestevenson.notifier.NonBlockingNotifier<T>
Type Parameters:
T - the type of data that the Notifier object handles.
All Implemented Interfaces:
Notifier<T>, java.lang.Runnable

public final class NonBlockingNotifier<T>
extends AbstractNotifier<T>
implements java.lang.Runnable

The non-blocking notifier is used to publish data to a set of interested subscribers, or Notifyees in an asynchronous fashion.

A notifyee may be any object that implements interface Notifyee. When an application calling the Notifer's publish method causes all of its notifyees to be notified of the change by a call to their update method.

The order in which notifications will be delivered is the order in which they registered interest. This implementation carries out delivery on a different thread to the publish call, and therefore does not block. It is up to the creator of this object to start this Runnable.

When a notifier object is newly created, its set of notifyees is empty.

Author:
Graeme Stevenson (graeme.stevenson@ucd.ie)

Constructor Summary
NonBlockingNotifier()
           
 
Method Summary
 void publish(T some_data)
          Passes the some_data argument to all registered notifyees via their update method.
 void run()
          Monitor the queue and notify all observers when new events are received.
 
Methods inherited from class com.graemestevenson.notifier.AbstractNotifier
addNotifyee, countNotifyees, deleteNotifyee, deleteNotifyees, shutdown
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonBlockingNotifier

public NonBlockingNotifier()
Method Detail

publish

public void publish(T some_data)
Passes the some_data argument to all registered notifyees via their update method. How this is handled is left to subclasses.

Specified by:
publish in interface Notifier<T>
Specified by:
publish in class AbstractNotifier<T>
Parameters:
some_data - the data to be passed to notifyees.

run

public void run()
Monitor the queue and notify all observers when new events are received.

Specified by:
run in interface java.lang.Runnable