JIVE Platform
Release 0.2.2

edu.bsu.cs.jive.util
Class Publisher<T>

java.lang.Object
  extended by edu.bsu.cs.jive.util.Publisher<T>
Type Parameters:
T - the type to which notification will be sent

public final class Publisher<T>
extends Object

Provides an efficient, thread-safe means of notifying listeners of an event. This technique has been taken from Allen Holub's book Holub on Patterns: Learning Design Patterns by Looking at Code (Apress, 2004). It has been extended to use generics.

See Also:
"Holub on Patterns: Learning Design Patterns by Looking at Code (Apress, 2004)"

Nested Class Summary
static interface Publisher.Distributor<S>
          Specifies an object that delivers messages to subcribers.
 
Constructor Summary
Publisher()
           
 
Method Summary
 void publish(Publisher.Distributor<T> deliveryAgent)
          Publish an event using a delivery agent.
 void subscribe(T subscriber)
          Add a new subscriber to this publisher.
 void unsubscribe(T subscriber)
          Cancel a subscription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Publisher

public Publisher()
Method Detail

publish

public void publish(Publisher.Distributor<T> deliveryAgent)
Publish an event using a delivery agent.

Parameters:
deliveryAgent - the agent that delivers the event

subscribe

public void subscribe(T subscriber)
Add a new subscriber to this publisher.

Parameters:
subscriber -

unsubscribe

public void unsubscribe(T subscriber)
Cancel a subscription

Parameters:
subscriber - the subscriber to remove

JIVE Platform
Release 0.2.2