public class AtmosphereResourceImpl extends java.lang.Object implements AtmosphereResource
AtmosphereResource.TRANSPORT| Modifier and Type | Field and Description |
|---|---|
protected AsyncSupport |
asyncSupport |
protected Broadcaster |
broadcaster |
static java.lang.String |
METEOR |
static java.lang.String |
PRE_SUSPEND |
protected javax.servlet.http.HttpSession |
session |
static java.lang.String |
SKIP_BROADCASTER_CREATION |
| Constructor and Description |
|---|
AtmosphereResourceImpl() |
AtmosphereResourceImpl(AtmosphereConfig config,
Broadcaster broadcaster,
AtmosphereRequest req,
AtmosphereResponse response,
AsyncSupport asyncSupport,
AtmosphereHandler atmosphereHandler)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
_destroy() |
Action |
action()
Return the
Action which represent the state of the response, e.g. |
AtmosphereResource |
addEventListener(AtmosphereResourceEventListener e)
|
AtmosphereResourceImpl |
atmosphereHandler(AtmosphereHandler atmosphereHandler) |
java.util.concurrent.ConcurrentLinkedQueue<AtmosphereResourceEventListener> |
atmosphereResourceEventListener() |
void |
cancel() |
AtmosphereResourceImpl |
cloneState(AtmosphereResource r) |
void |
close()
Close the underlying connection.
|
AtmosphereResourceImpl |
disableSuspend(boolean disableSuspend) |
boolean |
disableSuspendEvent()
Return true if
AtmosphereResourceEventListener.onSuspend(AtmosphereResourceEvent) and
AtmosphereResourceEventListener.onPreSuspend(AtmosphereResourceEvent) events are disabled. |
AtmosphereResourceImpl |
disableSuspendEvent(boolean disableSuspendEvent)
|
boolean |
forceBinaryWrite()
Return true when binary write is forced.
|
AtmosphereResource |
forceBinaryWrite(boolean forceBinaryWrite)
Force binary write and never write String value.
|
AtmosphereConfig |
getAtmosphereConfig()
Return the
AtmosphereConfig. |
AtmosphereHandler |
getAtmosphereHandler()
Return the associated
AtmosphereHandler associated with this resource. |
AtmosphereResourceEventImpl |
getAtmosphereResourceEvent()
Return the current
AtmosphereResourceEvent. |
Broadcaster |
getBroadcaster()
Return the current
Broadcaster. |
protected Broadcaster |
getBroadcaster(boolean autoCreate) |
AtmosphereRequest |
getRequest()
Return the underlying
AtmosphereRequest request. |
AtmosphereRequest |
getRequest(boolean enforceScope) |
AtmosphereResponse |
getResponse()
Return the
AtmosphereResponse. |
AtmosphereResponse |
getResponse(boolean enforceScope) |
Serializer |
getSerializer()
Get the
Serializer or null if not defined. |
AtmosphereResource |
initialize(AtmosphereConfig config,
Broadcaster broadcaster,
AtmosphereRequest req,
AtmosphereResponse response,
AsyncSupport asyncSupport,
AtmosphereHandler atmosphereHandler)
Initialize an
AtmosphereResource. |
boolean |
isCancelled()
Return true if this object has been cancelled.
|
boolean |
isInScope()
Check if the
AtmosphereRequest still is valid. |
boolean |
isResumed()
Return true if this object has been resumed.
|
boolean |
isSuspended()
Return true if the
AtmosphereResource.suspend() has been invoked. |
AtmosphereResource |
notifyListeners()
Notify all
AtmosphereResourceEventListeners. |
AtmosphereResource |
notifyListeners(AtmosphereResourceEvent event)
Notify all
AtmosphereResourceEventListener. |
void |
onThrowable(java.lang.Throwable t)
Notify
AtmosphereResourceEventListener thah an unexpected exception occured. |
AtmosphereResource |
removeEventListener(AtmosphereResourceEventListener e)
Remove a
AtmosphereResourceEventListener. |
AtmosphereResource |
removeEventListeners()
Remove all
AtmosphereResourceEventListeners. |
void |
reset()
Completely reset the instance to its initial state.
|
AtmosphereResource |
resume()
Complete the
AtmosphereResponse and finish/commit it. |
boolean |
resumeOnBroadcast()
Return true if this AtmosphereResource is resumed after the first broadcast.
|
AtmosphereResource |
resumeOnBroadcast(boolean resumeOnBroadcast)
Set to true to resume the response after the first broadcast.
|
javax.servlet.http.HttpSession |
session()
Return the
HttpSession if supported, null if not |
javax.servlet.http.HttpSession |
session(boolean create)
Return the
HttpSession if supported, and creates it if not already created. |
AtmosphereResourceImpl |
session(javax.servlet.http.HttpSession session) |
AtmosphereResourceImpl |
setBroadcaster(Broadcaster broadcaster)
Set the current
Broadcaster. |
void |
setIsInScope(boolean isInScope)
Protect the object from being used after it got cancelled.
|
AtmosphereResource |
setSerializer(Serializer s)
Set the
Serializer used to write broadcasted objects. |
AtmosphereResource |
suspend()
Suspend the
AtmosphereResponse indefinitely. |
AtmosphereResource |
suspend(long timeout)
Suspend the
AtmosphereResponse. |
AtmosphereResource |
suspend(long timeout,
java.util.concurrent.TimeUnit timeunit)
Suspend the
AtmosphereResponse. |
java.lang.String |
toString() |
AtmosphereResource.TRANSPORT |
transport()
Return the current
AtmosphereResource.TRANSPORT. |
AtmosphereResourceImpl |
transport(AtmosphereResource.TRANSPORT transport)
Manually set the
TRANSPORT |
java.lang.String |
uuid()
Return the unique ID associated with this AtmosphereResource.
|
AtmosphereResource |
write(byte[] o)
Write the bytes If
AtmosphereResource.resumeOnBroadcast() is true, the underlying connection will be resumed (@link #resume()); |
AtmosphereResource |
write(java.lang.String s)
Write the String.
|
java.lang.Object |
writeOnTimeout()
Return the object that will be written when the resource times out.
|
AtmosphereResource |
writeOnTimeout(java.lang.Object o)
Set a message that will be written when the resource times out.
|
public static final java.lang.String PRE_SUSPEND
public static final java.lang.String SKIP_BROADCASTER_CREATION
public static final java.lang.String METEOR
protected Broadcaster broadcaster
protected AsyncSupport asyncSupport
protected javax.servlet.http.HttpSession session
public AtmosphereResourceImpl()
@Deprecated public AtmosphereResourceImpl(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereRequest req, AtmosphereResponse response, AsyncSupport asyncSupport, AtmosphereHandler atmosphereHandler)
public AtmosphereResource initialize(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereRequest req, AtmosphereResponse response, AsyncSupport asyncSupport, AtmosphereHandler atmosphereHandler)
AtmosphereResource.initialize in interface AtmosphereResourceconfig - The AtmosphereConfigbroadcaster - The Broadcaster.req - The AtmosphereRequestresponse - The AtmosphereResourceasyncSupport - The AsyncSupportatmosphereHandler - The AtmosphereHandlerpublic AtmosphereResourceEventImpl getAtmosphereResourceEvent()
AtmosphereResourceAtmosphereResourceEvent.getAtmosphereResourceEvent in interface AtmosphereResourcepublic AtmosphereHandler getAtmosphereHandler()
AtmosphereResourceAtmosphereHandler associated with this resource.getAtmosphereHandler in interface AtmosphereResourceAtmosphereHandler associated with this resourcepublic AtmosphereResource writeOnTimeout(java.lang.Object o)
AtmosphereResourceObject or Callable.writeOnTimeout in interface AtmosphereResourcepublic java.lang.Object writeOnTimeout()
AtmosphereResourcewriteOnTimeout in interface AtmosphereResourcepublic java.lang.String uuid()
AtmosphereResourceuuid in interface AtmosphereResourcepublic AtmosphereResource.TRANSPORT transport()
AtmosphereResourceAtmosphereResource.TRANSPORT. The transport value is retrieved using the HeaderConfig.X_ATMOSPHERE_TRANSPORT
header value.transport in interface AtmosphereResourcepublic AtmosphereResourceImpl transport(AtmosphereResource.TRANSPORT transport)
TRANSPORTtransport - set the TRANSPORTpublic AtmosphereResource resumeOnBroadcast(boolean resumeOnBroadcast)
AtmosphereResourceresumeOnBroadcast in interface AtmosphereResourcepublic boolean isSuspended()
AtmosphereResourceAtmosphereResource.suspend() has been invoked.isSuspended in interface AtmosphereResourceAtmosphereResource.suspend() has been invokedpublic boolean resumeOnBroadcast()
AtmosphereResourceresumeOnBroadcast in interface AtmosphereResourceAtmosphereResource.resumeOnBroadcast()public AtmosphereResource resume()
AtmosphereResourceAtmosphereResponse and finish/commit it. If the AtmosphereResponse is in the
process of being resumed, invoking this method has no effect.resume in interface AtmosphereResourcepublic AtmosphereResource suspend()
AtmosphereResourceAtmosphereResponse indefinitely.
Suspending a AtmosphereResponse will tell the underlying container to avoid recycling objects associated
with the current instance, and also to avoid committing a response.
The Framework will output some HTML comments when suspending the response in order to make sure all browsers
work well with suspended responses.suspend in interface AtmosphereResourcepublic AtmosphereResource suspend(long timeout, java.util.concurrent.TimeUnit timeunit)
AtmosphereResourceAtmosphereResponse. Suspending a AtmosphereResponse will tell the underlying
container to avoid recycling objects associated with the current instance, and also to avoid committing response.
Invoking this method when a request is being timed out (e.g. AtmosphereResourceEvent.isResumedOnTimeout()
returns true) has no effect.
The Framework will output some HTML comments when suspending the response in order to make sure all browsers
work well with suspended responses. By default, the AtmosphereResponse.getWriter() will be used. You can
change that behavior by setting a request attribute named org.atmosphere.useStream so the framework will
use AtmosphereResponse.getOutputStream().suspend in interface AtmosphereResourcetimeout - The maximum amount of time a AtmosphereResponse can be suspended. When the timeout
expires, the AtmosphereResponse will be automatically resumed and committed. Usage of any
methods of a AtmosphereResponse that times out will throw an IllegalStateException.timeunit - The time unit of the timeout valuepublic AtmosphereResource suspend(long timeout)
AtmosphereResourceAtmosphereResponse. Suspending a AtmosphereResponse will tell the underlying
container to avoid recycling objects associated with the current instance, and also to avoid committing response.
Invoking this method when a request is being timed out (e.g. AtmosphereResourceEvent.isResumedOnTimeout()
returns true) has no effect.
The Framework will output some HTML comments when suspending the response in order to make sure all browsers
work well with suspended responses. By default, the AtmosphereResponse.getWriter() will be used. You can
change that behavior by setting a request attribute named org.atmosphere.useStream so the framework will
use AtmosphereResponse.getOutputStream().suspend in interface AtmosphereResourcetimeout - The maximum amount of time, in milliseconds, a AtmosphereResponse can be suspended. When
the timeout expires, the AtmosphereResponse will be automatically resumed and committed.
Usage of any methods of a AtmosphereResponse that times out will throw an IllegalStateException.public AtmosphereRequest getRequest(boolean enforceScope)
public AtmosphereResponse getResponse(boolean enforceScope)
public AtmosphereRequest getRequest()
AtmosphereResourceAtmosphereRequest request.getRequest in interface AtmosphereResourceAtmosphereRequest the underlying request.public AtmosphereResponse getResponse()
AtmosphereResourceAtmosphereResponse.getResponse in interface AtmosphereResourceAtmosphereResponse the underlying response.public Broadcaster getBroadcaster()
AtmosphereResourceBroadcaster.getBroadcaster in interface AtmosphereResourceBroadcasterprotected Broadcaster getBroadcaster(boolean autoCreate)
public AtmosphereResourceImpl setBroadcaster(Broadcaster broadcaster)
AtmosphereResourceBroadcaster. If null, a new Broadcaster will be created with Broadcaster.SCOPE.REQUEST
if that resource hasn't been suspended yet.setBroadcaster in interface AtmosphereResourcepublic AtmosphereConfig getAtmosphereConfig()
AtmosphereResourceAtmosphereConfig.getAtmosphereConfig in interface AtmosphereResourceAtmosphereConfigpublic Action action()
Action which represent the state of the response, e.g. suspended, resumed or timed out.Actionpublic void reset()
public void setIsInScope(boolean isInScope)
isInScope - public boolean isInScope()
AtmosphereRequest still is valid.AtmosphereRequest still is validpublic AtmosphereResource setSerializer(Serializer s)
Serializer used to write broadcasted objects.setSerializer in interface AtmosphereResources - public boolean isResumed()
AtmosphereResourceisResumed in interface AtmosphereResourcepublic boolean isCancelled()
AtmosphereResourceisCancelled in interface AtmosphereResourcepublic AtmosphereResource write(java.lang.String s)
AtmosphereResourceAtmosphereResource.resumeOnBroadcast() is true, the underlying connection will be resumed (@link #resume());write in interface AtmosphereResourcepublic AtmosphereResource write(byte[] o)
AtmosphereResourceAtmosphereResource.resumeOnBroadcast() is true, the underlying connection will be resumed (@link #resume());write in interface AtmosphereResourcepublic Serializer getSerializer()
AtmosphereResourceSerializer or null if not defined.getSerializer in interface AtmosphereResourceSerializer or null if not definedpublic AtmosphereResource addEventListener(AtmosphereResourceEventListener e)
addEventListener in interface AtmosphereResourcee - an instance of AtmosphereResourceEventListenerpublic AtmosphereResource removeEventListener(AtmosphereResourceEventListener e)
AtmosphereResourceAtmosphereResourceEventListener.removeEventListener in interface AtmosphereResourcepublic AtmosphereResource removeEventListeners()
AtmosphereResourceAtmosphereResourceEventListeners.removeEventListeners in interface AtmosphereResourcepublic AtmosphereResource notifyListeners()
AtmosphereResourceAtmosphereResourceEventListeners.notifyListeners in interface AtmosphereResourcepublic AtmosphereResource notifyListeners(AtmosphereResourceEvent event)
AtmosphereResourceAtmosphereResourceEventListener.notifyListeners in interface AtmosphereResourceevent - an instance of AtmosphereResourceEventpublic void onThrowable(java.lang.Throwable t)
AtmosphereResourceEventListener thah an unexpected exception occured.public java.util.concurrent.ConcurrentLinkedQueue<AtmosphereResourceEventListener> atmosphereResourceEventListener()
public AtmosphereResourceImpl atmosphereHandler(AtmosphereHandler atmosphereHandler)
public void cancel()
throws java.io.IOException
java.io.IOExceptionpublic void _destroy()
public java.lang.String toString()
toString in class java.lang.Objectpublic AtmosphereResourceImpl disableSuspend(boolean disableSuspend)
public javax.servlet.http.HttpSession session(boolean create)
AtmosphereResourceHttpSession if supported, and creates it if not already created.session in interface AtmosphereResourceHttpSession if supported, and creates it if not already createdpublic void close()
throws java.io.IOException
AtmosphereResourceAtmosphereResource}.close in interface AtmosphereResourcejava.io.IOExceptionpublic AtmosphereResource forceBinaryWrite(boolean forceBinaryWrite)
AtmosphereResourceforceBinaryWrite in interface AtmosphereResourcepublic boolean forceBinaryWrite()
AtmosphereResourceforceBinaryWrite in interface AtmosphereResourcepublic javax.servlet.http.HttpSession session()
AtmosphereResourceHttpSession if supported, null if notsession in interface AtmosphereResourceHttpSession if supported, null if notpublic AtmosphereResourceImpl session(javax.servlet.http.HttpSession session)
public AtmosphereResourceImpl cloneState(AtmosphereResource r)
public AtmosphereResourceImpl disableSuspendEvent(boolean disableSuspendEvent)
AtmosphereResourceEventListener.onSuspend(AtmosphereResourceEvent) and
AtmosphereResourceEventListener.onPreSuspend(AtmosphereResourceEvent). You normally disable those events
after the first onSuspend has been called so all transports behave the same way.
AtmosphereResourceEventListener marked with AllowInterceptor will not
be affected by this property.disableSuspendEvent - public boolean disableSuspendEvent()
AtmosphereResourceEventListener.onSuspend(AtmosphereResourceEvent) and
AtmosphereResourceEventListener.onPreSuspend(AtmosphereResourceEvent) events are disabled.Copyright © 2018. All Rights Reserved.