com.nexaweb.server.messaging
Interface MessagingService

All Superinterfaces:
Service

public interface MessagingService
extends Service

The MessagingService allows for system wide messaging. All MessageListeners subscribed on both clients and servers will hear messages published through this service.

A reference to this service may be obtained by calling the static ServiceManager.getMessagingService() method.

Example Usage:

     MessagingService messagingService = ServiceManager.getMessagingService();
     messagingService.publish( "MyTopic.MySubTopic", "My message" );

Topics specified to methods defined by this interface must consist only of alphanumeric characters and the following ( '-', '.', '_', ':' ).


Method Summary
 boolean isClientSubscribed(ServerSession session, java.lang.String topic)
          Returns true if the client for the specified ServerSession has a subscription to the specified topic.
 void publish(java.lang.String topic, byte[] array)
          Send a byte array to the subscribed listeners on both clients and servers.
 void publish(java.lang.String topic, Document document)
          Send a Document to the subscribed listeners on both clients and servers.
 void publish(java.lang.String topic, Element element)
          Send an Element and all of its descendants to the subscribed listeners on both clients and servers.
 void publish(java.lang.String topic, java.io.Serializable serializable)
          Send a Serializable object to the subscribed listeners on both clients and servers.
 void publish(java.lang.String topic, java.lang.String content)
          Send a String to the subscribed listeners on both clients and servers.
 void publish(java.lang.String topic, XmlSerializable xmlSerializable)
          Send an XmlSerializable object to the subscribed listeners on both clients and servers.
 void send(ServerSession session, java.lang.String topic, byte[] bytes)
          Send a byte array to subscribed listeners on the client.
 void send(ServerSession session, java.lang.String topic, Document document)
          Send a Document to subscribed listeners on the client.
 void send(ServerSession session, java.lang.String topic, Element element)
          Send an Element and all of its descendants to subscribed listeners on the client.
 void send(ServerSession session, java.lang.String topic, java.io.Serializable serializable)
          Send a Serializable object to subscribed listeners on the client.
 void send(ServerSession session, java.lang.String topic, java.lang.String content)
          Send a String to subscribed listeners on the client.
 void send(ServerSession session, java.lang.String topic, XmlSerializable xmlSerializable)
          Send an XmlSerializable object to subscribed listeners on the client.
 void sendAsynchronously(ServerSession session, java.lang.String topic, byte[] bytes)
          Send a byte array to subscribed listeners on the client.
 void sendAsynchronously(ServerSession session, java.lang.String topic, Document document)
          Send a Document to subscribed listeners on the client.
 void sendAsynchronously(ServerSession session, java.lang.String topic, Element element)
          Send an Element and all of its descendants to subscribed listeners on the client.
 void sendAsynchronously(ServerSession session, java.lang.String topic, java.io.Serializable serializable)
          Send a Serializable object to subscribed listeners on the client.
 void sendAsynchronously(ServerSession session, java.lang.String topic, java.lang.String content)
          Send a String to subscribed listeners on the client.
 void sendAsynchronously(ServerSession session, java.lang.String topic, XmlSerializable xmlSerializable)
          Send an XmlSerializable object to subscribed listeners on the client.
 void subscribe(java.lang.String topic, MessageListener listener)
          Subscribes the specified MessageListener to the specified topic.
 void unsubscribe(java.lang.String topic, MessageListener listener)
          Unsubscribes the specified MessageListener from the specified topic.
 
Methods inherited from interface com.nexaweb.server.services.Service
getDescription, getLog, getName, getPerformanceMeter, getStatus, getStatusReport, start, stop
 

Method Detail

publish

public void publish(java.lang.String topic,
                    Element element)
             throws MessageDispatchException
Send an Element and all of its descendants to the subscribed listeners on both clients and servers.

Parameters:
topic - The topic to which MessageListeners must be subscribed in order to receive the specified Element.
element - The Element to send.
Throws:
MessageDispatchException

publish

public void publish(java.lang.String topic,
                    Document document)
             throws MessageDispatchException
Send a Document to the subscribed listeners on both clients and servers.

Parameters:
topic - The topic to which MessageListeners must be subscribed in order to receive the specified Document.
document - The Document to send.
Throws:
MessageDispatchException

publish

public void publish(java.lang.String topic,
                    java.io.Serializable serializable)
             throws MessageDispatchException
Send a Serializable object to the subscribed listeners on both clients and servers. Note that if there are listeners on the client side, the specified Serializable object must be in the client classpath.

Parameters:
topic - The topic to which MessageListeners must be subscribed in order to receive the specified Serializable object.
serializable - The Serializable object to send.
Throws:
MessageDispatchException

publish

public void publish(java.lang.String topic,
                    XmlSerializable xmlSerializable)
             throws MessageDispatchException
Send an XmlSerializable object to the subscribed listeners on both clients and servers. Note that if there are listeners on the client side, the specified XmlSerializable object must be in the client classpath.

Parameters:
topic - The topic to which MessageListeners must be subscribed in order to receive the specified XmlSerializable object.
xmlSerializable - The XmlSerializable object to send.
Throws:
MessageDispatchException

publish

public void publish(java.lang.String topic,
                    byte[] array)
             throws MessageDispatchException
Send a byte array to the subscribed listeners on both clients and servers.

Parameters:
topic - The topic to which MessageListeners must be subscribed in order to receive the specified byte array.
array - The byte array to send.
Throws:
MessageDispatchException

publish

public void publish(java.lang.String topic,
                    java.lang.String content)
             throws MessageDispatchException
Send a String to the subscribed listeners on both clients and servers.

Parameters:
topic - The topic to which MessageListeners must be subscribed in order to receive the specified String.
content - The String to send.
Throws:
MessageDispatchException

send

public void send(ServerSession session,
                 java.lang.String topic,
                 Element element)
          throws MessageDispatchException
Send an Element and all of its descendants to subscribed listeners on the client. This method will block the calling thread until Element has been written to the client stream.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
element - The Element to send.
Throws:
MessageDispatchException - thrown if the message could not be sent.

sendAsynchronously

public void sendAsynchronously(ServerSession session,
                               java.lang.String topic,
                               Element element)
Send an Element and all of its descendants to subscribed listeners on the client. This method will queue the element for sending and return immediately.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
element - The Element to send.

send

public void send(ServerSession session,
                 java.lang.String topic,
                 Document document)
          throws MessageDispatchException
Send a Document to subscribed listeners on the client. This method will block the calling thread until the Document has been written to the client stream.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
Throws:
MessageDispatchException - thrown if the message could not be sent.

sendAsynchronously

public void sendAsynchronously(ServerSession session,
                               java.lang.String topic,
                               Document document)
Send a Document to subscribed listeners on the client. This method will queue the Document for sending and return immediately.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
document - The Document to send.

send

public void send(ServerSession session,
                 java.lang.String topic,
                 java.io.Serializable serializable)
          throws MessageDispatchException
Send a Serializable object to subscribed listeners on the client. This method will block the calling thread until the Serializable has been written to the client stream. Note that the specified Object's class definition must be in both the client and Server classpath.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
serializable - The Serializable object to send.
Throws:
MessageDispatchException - thrown if the message could not be sent.

sendAsynchronously

public void sendAsynchronously(ServerSession session,
                               java.lang.String topic,
                               java.io.Serializable serializable)
Send a Serializable object to subscribed listeners on the client. This method will queue the Serializable for sending and return immediately.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
serializable - The Serializable object to send.

send

public void send(ServerSession session,
                 java.lang.String topic,
                 XmlSerializable xmlSerializable)
          throws MessageDispatchException
Send an XmlSerializable object to subscribed listeners on the client. This method will block the calling thread until the XmlSerializable has been written to the client stream. Note that the specified Object's class definition must be in both the client and Server classpath. The Object will be instantiated on the client using a public no-args constructor and the object will be reconstituted from XML supplied by the server side object.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
xmlSerializable - The XmlSerializable object to send.
Throws:
MessageDispatchException - thrown if the message could not be sent.

sendAsynchronously

public void sendAsynchronously(ServerSession session,
                               java.lang.String topic,
                               XmlSerializable xmlSerializable)
Send an XmlSerializable object to subscribed listeners on the client. This method will queue the Serializable for sending and return immediately. The Object will be instantiated on the client using a public no-args constructor and the object will be reconstituted from XML supplied by the server side object.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
xmlSerializable - The XmlSerializable object to send.

send

public void send(ServerSession session,
                 java.lang.String topic,
                 byte[] bytes)
          throws MessageDispatchException
Send a byte array to subscribed listeners on the client. This method will block the calling thread until the array has been written to the client stream.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
Throws:
MessageDispatchException - thrown if the message could not be sent.

sendAsynchronously

public void sendAsynchronously(ServerSession session,
                               java.lang.String topic,
                               byte[] bytes)
Send a byte array to subscribed listeners on the client. This method will queue the array for sending and return immediately.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.

send

public void send(ServerSession session,
                 java.lang.String topic,
                 java.lang.String content)
          throws MessageDispatchException
Send a String to subscribed listeners on the client. This method will block the calling thread until the String has been written to the client stream.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
content - The String to send.
Throws:
MessageDispatchException - thrown if the message could not be sent.

sendAsynchronously

public void sendAsynchronously(ServerSession session,
                               java.lang.String topic,
                               java.lang.String content)
Send a String to subscribed listeners on the client. This method will queue the String for sending and return immediately.

Parameters:
session - The session to which the message should be sent.
topic - The topic to which MessageListeners must be subscribed on the client in order to receive this message.
content - The String to send.

subscribe

public void subscribe(java.lang.String topic,
                      MessageListener listener)
Subscribes the specified MessageListener to the specified topic.

Parameters:
topic - The topic that the MessageListener will be subscribed to.
listener - The MessageListener to notify when messages arrive on the specified topic.
Throws:
InvalidTopicException - thrown if the topic contains the '*' character.

unsubscribe

public void unsubscribe(java.lang.String topic,
                        MessageListener listener)
Unsubscribes the specified MessageListener from the specified topic.

Parameters:
topic - The topic that the MessageListener will be unsubscribed from.
listener - The MessageListener to unsubscribe.

isClientSubscribed

public boolean isClientSubscribed(ServerSession session,
                                  java.lang.String topic)
Returns true if the client for the specified ServerSession has a subscription to the specified topic.

Parameters:
session - The session to check.
topic - The topic to check.


Copyright © 2005 Nexaweb Technologies, Inc. All Rights Reserved.