02/28/2005
 

Package com.epicentric.topic

Provides an in-VM event framework for sending and receiving messages asynchronously.

See:
          Package Summary

Interface Summary
Subscriber The Subscriber interface needs to be implelemented by anyone that wants to subscribe to any topic.
 

Class Summary
TopicManager Singleton that manages publishing and subscribing of topics in a single VM.
TopicMessage The TopicMessage is used to publish information to any subscribers within the VM.
 

Package com.epicentric.topic Description

Provides an in-VM event framework for sending and receiving messages asynchronously. This framework is based on the Java Message Service (JMS) publish/subscribe model. An object that wants to inform others about a specific event is the publisher; an object that wants to receive messages is the subscriber. Messages get published in topics, which are organized hierarchically by dot-separated names--for example, "vgn.page.created" or "vgn.page.deleted".

Topics are created when needed. Neither messages nor subscriptions are persisted in the database.

Publishing

Sending a message involves creating the message and then calling the publish method on the TopicManager. For example:

TopicMessage message = new TopicMessage("vgn.site.deleted");
message.setProperty(TopicMessage.SITE_UID, site.getUID());
message.setProperty(PUBLISH_SITE_DELETED__SITE_TITLE, site.getTitle());
TopicManager.getInstance().publish(message);

Subscribing

Receiving messages involves implementing the Subscriber interface and subscribing to one or more topics. For example:

class LocalEventListener implements Subscriber {
    TopicManager.getInstance().subscribe("vgn.site.deleted", this);
}

The Subscriber interface has one method, onMessage(), which is called from a separate thread when a message is published in a topic to which the subscriber is subscribed.


02/28/2005
 

Copyright and Trademark Notices