cgl.imr.pubsub.nb
Class NBPubSubService

java.lang.Object
  extended by cgl.imr.pubsub.nb.NBPubSubService
All Implemented Interfaces:
PubSubService, cgl.narada.service.client.NBEventListener

public class NBPubSubService
extends Object
implements PubSubService, cgl.narada.service.client.NBEventListener

Abstract the NaradaBrokering's pub/sub communication. This class creates a single connection to the broker and use it to send and receive messages. A similar implementation may allow other pub/sub communication frameworks to be used with Twister.


Constructor Summary
NBPubSubService()
           
 
Method Summary
 void close()
          Cleanup the NaradaBrokering connections and profiles.
 void onEvent(cgl.narada.event.NBEvent nbMessage)
          Callback method for the NaradaBrokering.
 void send(String topic, byte[] message)
          Sends a byte[] message to a given String topic.
 void send(String topic, String message)
          Sends a String message to a given String topic.
 void setSubscriber(Subscribable callback)
          Sets the subscribable object for this PubSubService.
 void subscribe(String topic)
          Subscribe to a topic.
 void unsubscribe(String topic)
          Unsubscribe from a topic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NBPubSubService

public NBPubSubService()
                throws PubSubException
Throws:
PubSubException
Method Detail

close

public void close()
           throws PubSubException
Cleanup the NaradaBrokering connections and profiles.

Specified by:
close in interface PubSubService
Throws:
PubSubException

onEvent

public void onEvent(cgl.narada.event.NBEvent nbMessage)
Callback method for the NaradaBrokering. This method simply calls the subscribable's onEvent() method.

Specified by:
onEvent in interface cgl.narada.service.client.NBEventListener

send

public void send(String topic,
                 byte[] message)
          throws PubSubException
Sends a byte[] message to a given String topic.

Specified by:
send in interface PubSubService
Parameters:
topic - - Topic to send the message.
message - - Message to be sent as a byte[] array.
Throws:
PubSubException

send

public void send(String topic,
                 String message)
          throws PubSubException
Sends a String message to a given String topic.

Specified by:
send in interface PubSubService
Parameters:
topic - - Topic to send the message.
message - - Message to be sent.
Throws:
PubSubException

setSubscriber

public void setSubscriber(Subscribable callback)
                   throws PubSubException
Sets the subscribable object for this PubSubService.

Specified by:
setSubscriber in interface PubSubService
Parameters:
callback - - Subscribable object.
Throws:
PubSubException

subscribe

public void subscribe(String topic)
               throws PubSubException
Subscribe to a topic.

Specified by:
subscribe in interface PubSubService
Parameters:
topic - - Topic to be subscribed to.
Throws:
PubSubException

unsubscribe

public void unsubscribe(String topic)
                 throws PubSubException
Unsubscribe from a topic.

Specified by:
unsubscribe in interface PubSubService
Parameters:
topic - - Topic to to be unsubscribed.
Throws:
PubSubException


For comments and suggestions please send e-mail to