|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.jersey.server.Broadcaster<T>
public class Broadcaster<T>
Used for broadcasting response chunks to multiple ChunkedResponse instances.
| Constructor Summary | |
|---|---|
|
Broadcaster()
Creates a new instance. |
protected |
Broadcaster(boolean listen)
Can be used by subclasses to override the default functionality of adding self to the set of listeners by passing false as a parameter. |
| Method Summary | |
|---|---|
boolean |
add(ChunkedResponse<T> chunkedResponse)
Register ChunkedResponse 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 ChunkedResponse instances. |
void |
closeAll()
Close all registered ChunkedResponse instances. |
void |
onClose(ChunkedResponse<T> chunkedResponse)
Called when the chunkedResponse has been closed (either by client closing the connection or by calling ChunkedResponse.close() on the server side. |
void |
onException(ChunkedResponse<T> chunkedResponse,
Exception exception)
Called when exception was thrown by a given chunked response when trying to write to it or close it. |
boolean |
remove(ChunkedResponse<T> chunkedResponse)
Unregister ChunkedResponse from this Broadcaster instance. |
boolean |
removeBroadcasterListener(BroadcasterListener<T> listener)
Unregister BroadcasterListener. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Broadcaster()
onClose(ChunkedResponse) and onException(ChunkedResponse, Exception) methods, so it adds
the newly created instance as the listener. To avoid this, subclasses may call Broadcaster(boolean)
passing false as argument.
protected Broadcaster(boolean listen)
listeners by passing false as a parameter.
listen - if true, registers this instance as a listener (default), otherwise it doesn'tBroadcaster()| Method Detail |
|---|
public final boolean add(ChunkedResponse<T> chunkedResponse)
ChunkedResponse to this Broadcaster instance.
chunkedResponse - ChunkedResponse 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(ChunkedResponse<T> chunkedResponse)
ChunkedResponse from this Broadcaster instance.
This method does not close the ChunkedResponse being unregistered.
chunkedResponse - ChunkedResponse instance to unregister 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 listpublic 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
listenerspublic final void broadcast(T chunk)
ChunkedResponse instances.
chunk - chunk to be sent.public final void closeAll()
ChunkedResponse instances.
public void onException(ChunkedResponse<T> chunkedResponse,
Exception exception)
ChunkedResponse
instance when trying to write to it or close it.
onException in interface BroadcasterListener<T>chunkedResponse - instance that threw exception.exception - exception that was thrown.public void onClose(ChunkedResponse<T> chunkedResponse)
ChunkedResponse.close() on the server side.
Can be implemented by subclasses to hadnle the event of ChunkedResponse being closed.
onClose in interface BroadcasterListener<T>chunkedResponse - instance that was closed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||