Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.aendvari.hermes.broker
Class MessageBroker  view MessageBroker download MessageBroker.java

java.lang.Object
  extended bycom.aendvari.hermes.broker.MessageBroker

public class MessageBroker
extends java.lang.Object

Handles the subscription, publishing, and dispatching of messages.

Clients access the broker through MessageBrokerConnections. The connection provides the facilities for the client to subscribe and publish to the broker.


Field Summary
protected  MessageLogger logger
          When enabled, logs any messages published through this broker.
protected  com.aendvari.common.osm.Osm topics
          Contains the topic hierarchy.
 
Constructor Summary
MessageBroker()
          Constructs a MessageBroker.
 
Method Summary
 MessageBrokerConnection createConnection()
          Creates a MessageBrokerConnection for this broker.
 MessageLogger getLogger()
          Returns the MessageLogger of this broker.
protected  MessageTopic getTopic(MessageTopic parentTopic, java.lang.String topic)
          Returns a MessageTopic of the supplied relative path.
protected  MessageTopic getTopic(java.lang.String topic)
          Returns a MessageTopic of the supplied path.
protected  void publish(MessageTopic topic, Message message)
          Publishes a message to the specific topic.
protected  void subscribe(MessageTopic topic, MessageListener listener)
          Subscribes the listener to the specific topic.
protected  void unsubscribe(MessageTopic topic, MessageListener listener)
          Unsubscribes the listener from the specific topic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

topics

protected com.aendvari.common.osm.Osm topics
Contains the topic hierarchy. Subscribers are stored in collections within nodes of the tree.


logger

protected MessageLogger logger
When enabled, logs any messages published through this broker.

Constructor Detail

MessageBroker

public MessageBroker()
Constructs a MessageBroker.

Method Detail

getLogger

public MessageLogger getLogger()
Returns the MessageLogger of this broker.


createConnection

public MessageBrokerConnection createConnection()
Creates a MessageBrokerConnection for this broker.


getTopic

protected MessageTopic getTopic(java.lang.String topic)
Returns a MessageTopic of the supplied path. The MessageTopic returned may only be used with this MessageBroker. If the topic already exists, a reference to that topic is returned.


getTopic

protected MessageTopic getTopic(MessageTopic parentTopic,
                                java.lang.String topic)
Returns a MessageTopic of the supplied relative path. The path parameter is relative to the parent topic supplied. If the topic already exists, a reference to that topic is returned.


subscribe

protected void subscribe(MessageTopic topic,
                         MessageListener listener)
Subscribes the listener to the specific topic.


unsubscribe

protected void unsubscribe(MessageTopic topic,
                           MessageListener listener)
Unsubscribes the listener from the specific topic.


publish

protected void publish(MessageTopic topic,
                       Message message)
Publishes a message to the specific topic.