public class AtmosphereResourceImpl extends java.lang.Object implements AtmosphereResource
AtmosphereResource.TRANSPORT| Modifier and Type | Field and Description |
|---|---|
protected Action |
action |
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(AtmosphereConfig config,
Broadcaster broadcaster,
AtmosphereRequest req,
AtmosphereResponse response,
AsyncSupport asyncSupport,
AtmosphereHandler atmosphereHandler)
Create an
AtmosphereResource. |
| 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 |
cors() |
static java.lang.String |
createStreamingPadding(java.lang.String padding)
Output message when Atmosphere suspend a connection.
|
AtmosphereResourceImpl |
disableSuspend(boolean disableSuspend) |
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. |
boolean |
isCancelled()
Return true if this object has been cancelled.
|
boolean |
isInScope()
Is the
AtmosphereRequest still valid. |
boolean |
isResumed()
Return true if this object has been resumed.
|
boolean |
isSuspended()
Return true is the
AtmosphereResource.suspend() has been invoked. |
AtmosphereResource |
notifyListeners()
Notify All
AtmosphereResourceEventListener. |
AtmosphereResource |
notifyListeners(AtmosphereResourceEvent event)
Notify
AtmosphereResourceEventListener. |
void |
onThrowable(java.lang.Throwable t)
Notify
AtmosphereResourceEventListener an unexpected exception occured.\ |
AtmosphereResource |
padding(java.lang.String padding)
Set the padding to use when flushing the response when transport equals 'streaming' See
ApplicationConfig.STREAMING_PADDING_MODE
for more info. |
AtmosphereResource |
removeEventListener(AtmosphereResourceEventListener e)
Remove a
AtmosphereResourceEventListener. |
AtmosphereResource |
removeEventListeners()
Remove all
AtmosphereResourceEventListener. |
AtmosphereResource |
resume()
Complete the
AtmosphereResponse and finish/commit it. |
boolean |
resumeOnBroadcast()
Return the is the
AtmosphereResource.resumeOnBroadcast() |
AtmosphereResource |
resumeOnBroadcast(boolean resumeOnBroadcast)
Set to true to resume the response once after the first broadcast.
|
javax.servlet.http.HttpSession |
session()
Return the
HttpSession is supported, null if not |
javax.servlet.http.HttpSession |
session(boolean create)
Return the
HttpSession is 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 for being used after it got cancelled.
|
AtmosphereResource |
setSerializer(Serializer s)
Set the
Serializer used to write broadcasted object. |
AtmosphereResource |
suspend()
Suspend the
AtmosphereResponse indefinitely. |
AtmosphereResource |
suspend(long timeout)
Suspend the
AtmosphereResponse. |
AtmosphereResource |
suspend(long timeout,
boolean flushComment)
Suspend the
AtmosphereResponse. |
AtmosphereResource |
suspend(long timeout,
java.util.concurrent.TimeUnit timeunit)
Suspend the
AtmosphereResponse. |
AtmosphereResource |
suspend(long timeout,
java.util.concurrent.TimeUnit timeunit,
boolean flushComment)
Suspend the
AtmosphereResponse. |
java.lang.String |
toString() |
AtmosphereResource.TRANSPORT |
transport()
Return the current
AtmosphereResource.TRANSPORT. |
java.lang.String |
uuid()
Return the unique ID associated with this AtmosphereResource.
|
AtmosphereResource |
write(java.io.OutputStream os,
java.lang.Object o)
Write the broadcasted object using the
OutputStream. |
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 final Action action
protected Broadcaster broadcaster
protected final AsyncSupport asyncSupport
protected javax.servlet.http.HttpSession session
public AtmosphereResourceImpl(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereRequest req, AtmosphereResponse response, AsyncSupport asyncSupport, AtmosphereHandler atmosphereHandler)
AtmosphereResource.config - The AtmosphereConfigbroadcaster - The Broadcaster.req - The AtmosphereRequestresponse - The AtmosphereResourceasyncSupport - The AsyncSupportatmosphereHandler - The AtmosphereHandlerpublic AtmosphereResourceEventImpl getAtmosphereResourceEvent()
AtmosphereResourceEvent.getAtmosphereResourceEvent in interface AtmosphereResourcepublic AtmosphereHandler getAtmosphereHandler()
AtmosphereHandler associated with this resource.getAtmosphereHandler in interface AtmosphereResourceAtmosphereHandler associated with this resource.public AtmosphereResource writeOnTimeout(java.lang.Object o)
Object or CallablewriteOnTimeout in interface AtmosphereResourcepublic java.lang.Object writeOnTimeout()
writeOnTimeout in interface AtmosphereResourcepublic java.lang.String uuid()
AtmosphereResourceuuid in interface AtmosphereResourcepublic AtmosphereResource.TRANSPORT transport()
AtmosphereResource.TRANSPORT. The transport value is retrieved using the HeaderConfig.X_ATMOSPHERE_TRANSPORT
header value.transport in interface AtmosphereResourcepublic AtmosphereResource resumeOnBroadcast(boolean resumeOnBroadcast)
resumeOnBroadcast in interface AtmosphereResourcepublic boolean isSuspended()
AtmosphereResource.suspend() has been invoked.isSuspended in interface AtmosphereResourceAtmosphereResource.suspend() has been invoked.public boolean resumeOnBroadcast()
AtmosphereResource.resumeOnBroadcast()resumeOnBroadcast in interface AtmosphereResourcepublic AtmosphereResource resume()
AtmosphereResponse and finish/commit it. If the
AtmosphereResponse is in the process of being resumed, invoking
that method has no effect.resume in interface AtmosphereResourcepublic AtmosphereResource suspend()
AtmosphereResponse indefinitely.
Suspending a AtmosphereResponse will
tell the underlying container to avoid recycling objects associated with
the current instance, and also to avoid commiting response.
The Framework will output some HTML comments when suspending the response
in order to make sure all Browser works well with suspended response.suspend in interface AtmosphereResourcepublic AtmosphereResource suspend(long timeout)
AtmosphereResponse. Suspending a AtmosphereResponse will
tell the underlying container to avoid recycling objects associated with
the current instance, and also to avoid commiting response. Invoking
this method when a request is being timed out, e.g. AtmosphereResourceEvent.isResumedOnTimeout() return true,
has no effect.
The Framework will output some HTML comments when suspending the response
in order to make sure all Browser works well with suspended response. By default,
the AtmosphereResponse.getWriter() will be used. You can change that
behavior by setting a request attribute named org.atmosphere.useStream to
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 AtmosphereResource suspend(long timeout, java.util.concurrent.TimeUnit timeunit)
AtmosphereResponse. Suspending a AtmosphereResponse will
tell the underlying container to avoid recycling objects associated with
the current instance, and also to avoid commiting response. Invoking
this method when a request is being timed out, e.g. AtmosphereResourceEvent.isResumedOnTimeout() return true,
has no effect.
The Framework will output some HTML comments when suspending the response
in order to make sure all Browser works well with suspended response. By default,
the AtmosphereResponse.getWriter() will be used. You can change that
behavior by setting a request attribute named org.atmosphere.useStream to
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.timeunit - The time unit of the timeout valuepublic AtmosphereResource suspend(long timeout, java.util.concurrent.TimeUnit timeunit, boolean flushComment)
AtmosphereResponse. Suspending a AtmosphereResponse will
tell the underlying container to avoid recycling objects associated with
the current instance, and also to avoid commiting response. Invoking
this method when a request is being timed out, e.g. AtmosphereResourceEvent.isResumedOnTimeout() return true,
has no effect.
The Framework will output some HTML comments when suspending the response
in order to make sure all Browser works well with suspended response. By default,
the AtmosphereResponse.getWriter() will be used. You can change that
behavior by setting a request attribute named org.atmosphere.useStream to
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.timeunit - The time unit of the timeout valueflushComment - By default, Atmosphere will output some comments to make WebKit based
browser working. Set it to false if you want to remove it.public AtmosphereResource suspend(long timeout, boolean flushComment)
AtmosphereResourceAtmosphereResponse. Suspending a AtmosphereResponse will
tell the underlying container to avoid recycling objects associated with
the current instance, and also to avoid commiting response. Invoking
this method when a request is being timed out, e.g. AtmosphereResourceEvent.isResumedOnTimeout() return true,
has no effect.
The Framework will output some HTML comments when suspending the response
in order to make sure all Browser works well with suspended response. By default,
the AtmosphereResponse.getWriter() will be used. You can change that
behavior by setting a request attribute named org.atmosphere.useStream to
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.flushComment - By default, Atmosphere will output some comments to make WebKit based
browser working. Set it to false if you want to remove it.public AtmosphereRequest getRequest(boolean enforceScope)
public AtmosphereResponse getResponse(boolean enforceScope)
public AtmosphereRequest getRequest()
AtmosphereRequest Request.getRequest in interface AtmosphereResourceAtmosphereRequest the underlying Request.public AtmosphereResponse getResponse()
AtmosphereResponsegetResponse in interface AtmosphereResourceAtmosphereResponse the underlying Response.public Broadcaster getBroadcaster()
BroadcastergetBroadcaster in interface AtmosphereResourceBroadcasterprotected Broadcaster getBroadcaster(boolean autoCreate)
public AtmosphereResourceImpl setBroadcaster(Broadcaster broadcaster)
Broadcaster. If null, a new Broadcaster will be created with Broadcaster.SCOPE.REQUEST
will be created if that resource hasn't been yet suspended.setBroadcaster in interface AtmosphereResourcepublic AtmosphereConfig getAtmosphereConfig()
AtmosphereConfiggetAtmosphereConfig in interface AtmosphereResourceAtmosphereConfigpublic Action action()
Action which represent the state of the response,
e.g. suspended, resumed or timedout.Actionpublic void setIsInScope(boolean isInScope)
isInScope - public boolean isInScope()
AtmosphereRequest still valid.AtmosphereRequest still validpublic AtmosphereResource setSerializer(Serializer s)
Serializer used to write broadcasted object.setSerializer in interface AtmosphereResources - public boolean isResumed()
isResumed in interface AtmosphereResourcepublic boolean isCancelled()
isCancelled in interface AtmosphereResourcepublic AtmosphereResource write(java.io.OutputStream os, java.lang.Object o) throws java.io.IOException
OutputStream. If a
Serializer is defined, the operation will be delagated to it. If
not, the write in interface AtmosphereResourceos - an OutputStreamo - an Objectjava.io.IOExceptionpublic Serializer getSerializer()
Serializer or null if not defined.getSerializer in interface AtmosphereResourceSerializer or null if not defined.public static java.lang.String createStreamingPadding(java.lang.String padding)
public AtmosphereResource addEventListener(AtmosphereResourceEventListener e)
addEventListener in interface AtmosphereResourcee - an instance of AtmosphereResourceEventListenerpublic AtmosphereResource removeEventListener(AtmosphereResourceEventListener e)
AtmosphereResourceEventListener.removeEventListener in interface AtmosphereResourcepublic AtmosphereResource removeEventListeners()
AtmosphereResourceEventListener.removeEventListeners in interface AtmosphereResourcepublic AtmosphereResource notifyListeners()
AtmosphereResourceEventListener.notifyListeners in interface AtmosphereResourcepublic AtmosphereResource notifyListeners(AtmosphereResourceEvent event)
AtmosphereResourceEventListener.notifyListeners in interface AtmosphereResourceevent - an instance of AtmosphereResourceEventpublic void onThrowable(java.lang.Throwable t)
AtmosphereResourceEventListener 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)
HttpSession is supported, and creates it if not already created.session in interface AtmosphereResourceHttpSession is supported, and creates it if not already createdpublic AtmosphereResource padding(java.lang.String padding)
ApplicationConfig.STREAMING_PADDING_MODE
for more info.padding in interface AtmosphereResourcepublic javax.servlet.http.HttpSession session()
HttpSession is supported, null if notsession in interface AtmosphereResourceHttpSession is supported, null if notpublic AtmosphereResourceImpl session(javax.servlet.http.HttpSession session)
public AtmosphereResourceImpl cloneState(AtmosphereResource r)
public void cors()
Copyright © 2018. All Rights Reserved.