|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.croftsoft.core.util.pubsub.ArrayPublisher
public final class ArrayPublisher
A synchronous Publisher implementation backed by a Subscriber array.
In this simple Publisher implementation, message propagation is synchronous; all of the methods are synchronized and the publish() method does not return until all Subscribers have been contacted one-at-a-time and in array order.
Java 1.1 compatible.
Publisher
,
Subscriber
Constructor Summary | |
---|---|
ArrayPublisher()
this ( null, new Subscriber [ ] { } ); |
|
ArrayPublisher(ExceptionHandler exceptionHandler,
Subscriber[] subscribers)
|
Method Summary | |
---|---|
boolean |
addSubscriber(Subscriber subscriber)
|
void |
publish(Object message)
|
void |
receive(Object message)
Simply calls method publish(message) . |
boolean |
removeSubscriber(Subscriber subscriber)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ArrayPublisher(ExceptionHandler exceptionHandler, Subscriber[] subscribers)
exceptionHandler
- Handles any Exceptions thrown by Subscriber.receive().
If null, exception.printStackTrace() will be used by default.public ArrayPublisher()
Method Detail |
---|
public boolean addSubscriber(Subscriber subscriber)
addSubscriber
in interface Publisher
public boolean removeSubscriber(Subscriber subscriber)
removeSubscriber
in interface Publisher
public void publish(Object message)
publish
in interface Publisher
public void receive(Object message)
Publisher
publish(message)
.
This interface extends interface Subscriber so that it can be used as a one-to-many relay; received messages are published.
receive
in interface Publisher
receive
in interface Subscriber
|
CroftSoft Javadoc | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |