org.glassfish.jersey.media.sse
Class Broadcaster

java.lang.Object
  extended by org.glassfish.jersey.media.sse.Broadcaster

public class Broadcaster
extends java.lang.Object

Used for broadcasting sse to multiple EventChannel instances.

Author:
Pavel Bucek (pavel.bucek at oracle.com)

Constructor Summary
Broadcaster()
           
 
Method Summary
 void broadcast(java.lang.Object data, java.lang.Class<?> dataType)
          Broadcast a message with given parameters to all registered EventChannel instances.
 void broadcast(java.lang.String eventName, java.lang.Object data, java.lang.Class<?> dataType)
          Broadcast a message with given parameters to all registered EventChannel instances.
 void broadcast(java.lang.String eventName, java.lang.String eventId, java.lang.Class dataType, java.lang.Object data)
          Broadcast a message with given parameters to all registered EventChannel instances.
 void close()
          Close all registered EventChannel instances.
 void registerEventChannel(EventChannel eventChannel)
          Register EventChannel to current Broadcaster instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Broadcaster

public Broadcaster()
Method Detail

registerEventChannel

public void registerEventChannel(EventChannel eventChannel)
Register EventChannel to current Broadcaster instance.

Parameters:
eventChannel - EventChannel to register.

broadcast

public void broadcast(java.lang.String eventName,
                      java.lang.String eventId,
                      java.lang.Class dataType,
                      java.lang.Object data)
               throws java.lang.IllegalStateException,
                      java.lang.IllegalArgumentException
Broadcast a message with given parameters to all registered EventChannel instances.

Parameters:
eventName - event name.
eventId - event id.
dataType - Class which will be used for MessageBodyWriter lookup. MUST NOT be null.
data - actual data. MUST NOT be null.
Throws:
java.lang.IllegalStateException - when trying to write message to closed EventChannel.
java.lang.IllegalArgumentException - when dataType or data is null.

broadcast

public void broadcast(java.lang.String eventName,
                      java.lang.Object data,
                      java.lang.Class<?> dataType)
               throws java.lang.IllegalStateException,
                      java.lang.IllegalArgumentException
Broadcast a message with given parameters to all registered EventChannel instances.

Parameters:
eventName - event name.
dataType - Class which will be used for MessageBodyWriter lookup. MUST NOT be null.
data - actual data. MUST NOT be null.
Throws:
java.lang.IllegalStateException - when trying to write message to closed EventChannel.
java.lang.IllegalArgumentException - when dataType or data is null.

broadcast

public void broadcast(java.lang.Object data,
                      java.lang.Class<?> dataType)
               throws java.lang.IllegalStateException,
                      java.lang.IllegalArgumentException
Broadcast a message with given parameters to all registered EventChannel instances.

Parameters:
dataType - Class which will be used for MessageBodyWriter lookup. MUST NOT be null.
data - actual data. MUST NOT be null.
Throws:
java.lang.IllegalStateException - when trying to write message to closed EventChannel.
java.lang.IllegalArgumentException - when dataType or data is null.

close

public void close()
Close all registered EventChannel instances.



Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.