|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.glassfish.jersey.media.sse.EventChannel
public class EventChannel
Outgoing event message queue. When returned from resource method, underlying connection is kept open and application is able to write messages. One instance of this class corresponds with exactly one HTTP connection.
| Field Summary | |
|---|---|
static java.lang.String |
SERVER_SENT_EVENTS
String representation of Server sent events media type. |
static MediaType |
SERVER_SENT_EVENTS_TYPE
Server sent events media type. |
| Constructor Summary | |
|---|---|
EventChannel()
Default constructor. |
|
EventChannel(java.lang.Long interval,
java.util.concurrent.TimeUnit timeUnit)
Create EventChannel with specified type and polling interval. |
|
| Method Summary | |
|---|---|
void |
close()
Close underlying outgoing connection |
boolean |
isClosed()
Get information about EventChannel state. |
void |
write(java.lang.Object data,
java.lang.Class<?> dataType)
Send a message with given parameters. |
void |
write(java.lang.String eventName,
java.lang.Object data,
java.lang.Class<?> dataType)
Send a message with given parameters. |
void |
write(java.lang.String eventName,
java.lang.String eventId,
java.lang.Object data,
java.lang.Class<?> dataType)
Send a message with given parameters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SERVER_SENT_EVENTS
String representation of Server sent events media type. (""text/event-stream"").
public static final MediaType SERVER_SENT_EVENTS_TYPE
| Constructor Detail |
|---|
public EventChannel()
public EventChannel(java.lang.Long interval,
java.util.concurrent.TimeUnit timeUnit)
EventChannel with specified type and polling interval. Polling interval is used when retrieving
data - basically it specifies how often will be connection checked if it is closed from the client side.
interval - polling interval. Default value is 5.timeUnit - polling interval TimeUnit. Default value is TimeUnit.SECONDS.| Method Detail |
|---|
public void write(java.lang.String eventName,
java.lang.String eventId,
java.lang.Object data,
java.lang.Class<?> dataType)
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException
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.
java.lang.IllegalStateException - when trying to write message to closed EventChannel.
java.lang.IllegalArgumentException - when dataType or data is null.
public void write(java.lang.String eventName,
java.lang.Object data,
java.lang.Class<?> dataType)
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException
eventName - event name.dataType - Class which will be used for MessageBodyWriter lookup.
MUST NOT be null.data - actual data. MUST NOT be null.
java.lang.IllegalStateException - when trying to write message to closed EventChannel.
java.lang.IllegalArgumentException - when dataType or data is null.
public void write(java.lang.Object data,
java.lang.Class<?> dataType)
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException
dataType - Class which will be used for MessageBodyWriter lookup.
MUST NOT be null.data - actual data. MUST NOT be null.
java.lang.IllegalStateException - when trying to write message to closed EventChannel.
java.lang.IllegalArgumentException - when dataType or data is null.public boolean isClosed()
EventChannel state.
true when EventChannel is closed, otherwise false.public void close()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||