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

Quick Search    Search Deep

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

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

public class MessageBrokerConnection
extends java.lang.Object

Represents a client connection to a MessageBroker.

The connection has a MessageBrokerContext associated with it. The context contains client specific data (such as HTTP information, see com.aendvari.hermes.broker.http.HttpMessageBrokerContext). This context is provided with each published Message.

The MessageBroker and MessageBrokerConnection provide a simple transaction facility. Messages published while the transaction is active are held until the transaction is commited or rolled back. When commited, all the messages published are sent. When rolled back, all the messages are ignored.


Field Summary
protected  MessageBroker broker
          The MessageBroker that this connection is for.
protected  MessageBrokerContext brokerContext
          The MessageBrokerContext associated with this connection.
protected  MessageTransaction transaction
          Handles message transactions.
 
Constructor Summary
protected MessageBrokerConnection(MessageBroker setBroker)
          Constructs a MessageBrokerConnection with a default context.
 
Method Summary
 MessageBatch createBatch()
          Creates a MessageBatch for this connection.
 Message createMessage()
          Creates a Message for this connection.
 MessageBrokerContext getContext()
          Returns the MessageBrokerContext of this connection.
 MessageTopic getTopic(MessageTopic parentTopic, java.lang.String topic)
          Returns a MessageTopic.
 MessageTopic getTopic(java.lang.String topic)
          Returns a MessageTopic of the specified path.
 MessageTransaction getTransaction()
          Returns the MessageTransaction of this connection.
 void publish(MessageTopic topic, Message message)
          Publishes a message to the specific topic.
 void setContext(MessageBrokerContext setContext)
          Sets the MessageBrokerContext of this connection.
 void subscribe(MessageTopic topic, MessageListener listener)
          Subscribes the listener to the specified topic.
 void subscribe(java.lang.String topic, MessageListener listener)
          Subscribes the listener to the specific topic.
 void unsubscribe(MessageTopic topic, MessageListener listener)
          Unsubscribes the listener from the specified topic.
 void unsubscribe(java.lang.String topic, MessageListener listener)
          Unsubscribes the listener form the specific topic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

broker

protected MessageBroker broker
The MessageBroker that this connection is for.


brokerContext

protected MessageBrokerContext brokerContext
The MessageBrokerContext associated with this connection.


transaction

protected MessageTransaction transaction
Handles message transactions.

Constructor Detail

MessageBrokerConnection

protected MessageBrokerConnection(MessageBroker setBroker)
Constructs a MessageBrokerConnection with a default context.

Method Detail

getContext

public MessageBrokerContext getContext()
Returns the MessageBrokerContext of this connection.


setContext

public void setContext(MessageBrokerContext setContext)
Sets the MessageBrokerContext of this connection.


getTransaction

public MessageTransaction getTransaction()
Returns the MessageTransaction of this connection.


getTopic

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


getTopic

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


subscribe

public void subscribe(MessageTopic topic,
                      MessageListener listener)
Subscribes the listener to the specified topic.


unsubscribe

public void unsubscribe(MessageTopic topic,
                        MessageListener listener)
Unsubscribes the listener from the specified topic.


subscribe

public void subscribe(java.lang.String topic,
                      MessageListener listener)
Subscribes the listener to the specific topic. The topic is specified by it's path. A search is performed to find the topic in the hierarchy.


unsubscribe

public void unsubscribe(java.lang.String topic,
                        MessageListener listener)
Unsubscribes the listener form the specific topic. The topic is specified by it's path. A search is performed to find the topic in the hierarchy.


publish

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


createMessage

public Message createMessage()
Creates a Message for this connection.


createBatch

public MessageBatch createBatch()
Creates a MessageBatch for this connection.