org.glassfish.jersey.media.sse
Class OutboundEvent

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

public final class OutboundEvent
extends Object

Representation of a single outbound SSE event.

Author:
Pavel Bucek (pavel.bucek at oracle.com), Marek Potociar (marek.potociar at oracle.com)

Nested Class Summary
static class OutboundEvent.Builder
          Used for creating OutboundEvent instances.
 
Method Summary
 String getComment()
          Get a comment string that accompanies the event.
 Object getData()
          Get event data.
 Type getGenericType()
          Get generic data type.
 String getId()
          Get event identifier.
 javax.ws.rs.core.MediaType getMediaType()
          Get media type of the event data.
 String getName()
          Get event name.
 long getReconnectDelay()
          Get connection retry time in milliseconds the event receiver should wait before attempting to reconnect after a connection to the SSE source is lost.
 Class<?> getType()
          Get data type.
 boolean isReconnectDelaySet()
          Check if the connection retry time has been set in the event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public String getName()
Get event name.

This field is optional. If specified, will be send as a value of the SSE "event" field.

Returns:
event name, or null if not set.

getId

public String getId()
Get event identifier.

This field is optional. If specified, the value is send as a value of the SSE "id" field.

Returns:
event identifier, or null if not set.

getReconnectDelay

public long getReconnectDelay()
Get connection retry time in milliseconds the event receiver should wait before attempting to reconnect after a connection to the SSE source is lost.

This field is optional. If specified, the value is send as a value of the SSE "retry" field.

Returns:
reconnection delay in milliseconds or SseFeature.RECONNECT_NOT_SET if no value has been set.
Since:
2.3

isReconnectDelaySet

public boolean isReconnectDelaySet()
Check if the connection retry time has been set in the event.

Returns:
true if reconnection delay in milliseconds has been set in the event, false otherwise.
Since:
2.3

getType

public Class<?> getType()
Get data type.

This information is used to select a proper MessageBodyWriter to be used for serializing the event data.

Returns:
data type.

getGenericType

public Type getGenericType()
Get generic data type.

This information is used to select a proper MessageBodyWriter to be used for serializing the event data.

Returns:
generic data type.
Since:
2.3

getMediaType

public javax.ws.rs.core.MediaType getMediaType()
Get media type of the event data.

This information is used to a select proper MessageBodyWriter to be used for serializing the event data.

Returns:
data MediaType.

getComment

public String getComment()
Get a comment string that accompanies the event.

If specified, the comment value is sent with the event as one or more SSE comment lines (depending on line breaks in the actual data string), before any actual event data are serialized. If the event instance does not contain any data, a separate "event" that contains only the comment will be sent. Comment information is optional, provided the event data are set.

Returns:
comment associated with the event.

getData

public Object getData()
Get event data.

The event data, if specified, are serialized and sent as one or more SSE event "data" fields (depending on the line breaks in the actual serialized data content). The data are serialized using an available MessageBodyWriter that is selected based on the event type, getGenericType() generic type} and getMediaType() media type}.

Returns:
event data.


Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.