org.glassfish.jersey.media.sse
Class OutboundEvent.Builder

java.lang.Object
  extended by org.glassfish.jersey.media.sse.OutboundEvent.Builder
Enclosing class:
OutboundEvent

public static class OutboundEvent.Builder
extends java.lang.Object

Used for creating OutboundEvent instances.


Constructor Summary
OutboundEvent.Builder()
           
 
Method Summary
 OutboundEvent build()
          Build OutboundEvent.
 OutboundEvent.Builder comment(java.lang.String comment)
          Set comment.
 OutboundEvent.Builder data(java.lang.Class type, java.lang.Object data)
          Set event data and java type of event data.
 OutboundEvent.Builder id(java.lang.String id)
          Set event id.
 OutboundEvent.Builder mediaType(MediaType mediaType)
          Set MediaType of event data.
 OutboundEvent.Builder name(java.lang.String name)
          Set event name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutboundEvent.Builder

public OutboundEvent.Builder()
Method Detail

name

public OutboundEvent.Builder name(java.lang.String name)
Set event name. Will be send as field name "event".

Parameters:
name - field name "event" value.
Returns:
updated builder instance.

id

public OutboundEvent.Builder id(java.lang.String id)
Set event id.

Parameters:
id - event id.
Returns:
updated builder instance.

mediaType

public OutboundEvent.Builder mediaType(MediaType mediaType)
Set MediaType of event data.

When it is set, it will be used for MessageBodyWriter lookup. Default value is MediaType.TEXT_PLAIN.

Parameters:
mediaType - MediaType of event data.
Returns:
updated builder instance.

comment

public OutboundEvent.Builder comment(java.lang.String comment)
Set comment. It will be send before serialized event if it contains data or as a separate "event".

Parameters:
comment - comment string.
Returns:
updated builder instance.

data

public OutboundEvent.Builder data(java.lang.Class type,
                                  java.lang.Object data)
Set event data and java type of event data. Type will be used for MessageBodyWriter lookup.

Parameters:
type - java type of supplied data. MUST NOT be null.
data - event data. MUST NOT be null.
Returns:
updated builder instance.

build

public OutboundEvent build()
                    throws java.lang.IllegalStateException
Build OutboundEvent.

There are two valid configurations:

Returns:
new OutboundEvent instance.
Throws:
java.lang.IllegalStateException - when called with invalid configuration.


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