|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.jersey.server.Broadcaster<T>
T - broadcast type.public class Broadcaster<T>
Used for broadcasting response chunks to multiple ChunkedOutput instances.
| Constructor Summary | |
|---|---|
|
Broadcaster()
Creates a new instance. |
protected |
Broadcaster(Class<? extends Broadcaster> subclass)
Can be used by subclasses to override the default functionality of adding self to the set of listeners. |
| Method Summary | |
|---|---|
boolean |
add(ChunkedOutput<T> chunkedOutput)
Register ChunkedOutput to this Broadcaster instance. |
boolean |
addBroadcasterListener(BroadcasterListener<T> listener)
Register BroadcasterListener for Broadcaster events listening. |
void |
broadcast(T chunk)
Broadcast a chunk to all registered ChunkedOutput instances. |
void |
closeAll()
Close all registered ChunkedOutput instances. |
void |
onClose(ChunkedOutput<T> chunkedOutput)
Called when the chunkedOutput has been closed (either by client closing the connection or by calling ChunkedOutput.close() on the server side. |
void |
onException(ChunkedOutput<T> chunkedOutput,
Exception exception)
Called when exception was thrown by a given chunked response when trying to write to it or close it. |
boolean |
remove(ChunkedOutput<T> chunkedOutput)
Un-register ChunkedOutput from this Broadcaster instance. |
boolean |
removeBroadcasterListener(BroadcasterListener<T> listener)
Un-register BroadcasterListener. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Broadcaster()
onClose(ChunkedOutput) and onException(ChunkedOutput, Exception) methods, so it adds
the newly created instance as the listener. To avoid this, subclasses may call Broadcaster(Class)
passing their class as an argument.
protected Broadcaster(Class<? extends Broadcaster> subclass)
listeners. If creating a direct instance of a subclass passed in the parameter,
the broadcaster will not register itself as a listener.
subclass - subclass of Broadcaster that should not be registered as a listener - if creating a direct instance
of this subclass, this constructor will not register the new instance as a listener.Broadcaster()| Method Detail |
|---|
public final boolean add(ChunkedOutput<T> chunkedOutput)
ChunkedOutput to this Broadcaster instance.
chunkedOutput - ChunkedOutput to register.
true if the instance was successfully registered, false if this instance was already in
the list of registered chunked responses.public final boolean remove(ChunkedOutput<T> chunkedOutput)
ChunkedOutput from this Broadcaster instance.
This method does not close the ChunkedOutput being unregistered.
chunkedOutput - ChunkedOutput instance to un-register from this broadcaster.
true if the instance was unregistered, false if the instance wasn't found in the list
of registered chunked responses.public final boolean addBroadcasterListener(BroadcasterListener<T> listener)
BroadcasterListener for Broadcaster events listening.
listener - listener to be registered
true if registered, false if the listener was already in the list
TODO renamepublic final boolean removeBroadcasterListener(BroadcasterListener<T> listener)
BroadcasterListener.
listener - listener to be unregistered
true if unregistered, false if the listener was not found in the list of registered
listeners
TODO renamepublic void broadcast(T chunk)
ChunkedOutput instances.
chunk - chunk to be sent.public void closeAll()
ChunkedOutput instances.
public void onException(ChunkedOutput<T> chunkedOutput,
Exception exception)
ChunkedOutput
instance when trying to write to it or close it.
onException in interface BroadcasterListener<T>chunkedOutput - instance that threw exception.exception - exception that was thrown.public void onClose(ChunkedOutput<T> chunkedOutput)
ChunkedOutput.close() on the server side.
Can be implemented by subclasses to hadnle the event of ChunkedOutput being closed.
onClose in interface BroadcasterListener<T>chunkedOutput - instance that was closed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||