Package org.atmosphere.jersey
Class SuspendResponse<E>
java.lang.Object
com.sun.jersey.api.JResponse
org.atmosphere.jersey.SuspendResponse<E>
- Type Parameters:
E- thetype
public class SuspendResponse<E>
extends com.sun.jersey.api.JResponse
This class can be used to suspend response programmatically, similar to
Suspend
annotation.
SuspendResponse<String> r = new SuspendResponse.SuspendResponseBuilder<String>()
.broadcaster(broadcaster)
.outputComments(true)
.period(5, TimeUnit.SECONDS)
.entity("foo")
.build();
- Author:
- Jeanfrancois Arcand
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA Builder forSuspendResponsestatic classUtil class that encapsulate a period and a TimeUnit.Nested classes/interfaces inherited from class com.sun.jersey.api.JResponse
com.sun.jersey.api.JResponse.AJResponseBuilder<E,B extends com.sun.jersey.api.JResponse.AJResponseBuilder>, com.sun.jersey.api.JResponse.JResponseBuilder<E> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionorg.atmosphere.cpr.BroadcasterReturn theBroadcasterthat will be used to broadcast events.Collection<org.atmosphere.cpr.AtmosphereResourceEventListener> Return the current list ofAtmosphereResourceEventListenerclasses.booleanTell Atmosphere to write some comments during the connection suspension.period()Return theSuspendResponse.TimeSpanused to suspend the response.booleanResume the connection on the firstBroadcaster.broadcast(Object)operations.org.atmosphere.annotation.Suspend.SCOPEscope()Return theSuspend.SCOPEvalue.booleanWrite the returned entity back to the calling connection.Methods inherited from class com.sun.jersey.api.JResponse
created, fromResponse, fromResponse, getEntity, getMetadata, getStatus, getStatusType, getType, noContent, notAcceptable, notModified, notModified, notModified, ok, ok, ok, ok, ok, seeOther, serverError, status, status, status, temporaryRedirect, toResponse, toResponse
-
Constructor Details
-
SuspendResponse
-
-
Method Details
-
scope
public org.atmosphere.annotation.Suspend.SCOPE scope()Return theSuspend.SCOPEvalue.- Returns:
- the
Suspend.SCOPEvalue.
-
period
Return theSuspendResponse.TimeSpanused to suspend the response.- Returns:
- the
SuspendResponse.TimeSpanused to suspend the response.
-
outputComments
public boolean outputComments()Tell Atmosphere to write some comments during the connection suspension.- Returns:
- true is comment will be written.
-
resumeOnBroadcast
public boolean resumeOnBroadcast()Resume the connection on the firstBroadcaster.broadcast(Object)operations.- Returns:
- true if the connection needs to be resumed.
-
writeEntity
public boolean writeEntity()Write the returned entity back to the calling connection. Default is false. -
broadcaster
public org.atmosphere.cpr.Broadcaster broadcaster()Return theBroadcasterthat will be used to broadcast events.- Returns:
- the
Broadcasterthat will be used to broadcast events.
-
listeners
Return the current list ofAtmosphereResourceEventListenerclasses.- Returns:
- the current list of
AtmosphereResourceEventListenerclasses.
-