|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.atmosphere.cpr.AtmosphereResourceImpl
public class AtmosphereResourceImpl
AtmosphereResource implementation for supporting HttpServletRequest
and HttpServletResponse.
| Field Summary | |
|---|---|
protected AtmosphereServlet.Action |
action
|
protected Broadcaster |
broadcaster
|
protected CometSupport |
cometSupport
|
static String |
METEOR
|
static String |
PRE_SUSPEND
|
static String |
SKIP_BROADCASTER_CREATION
|
| Constructor Summary | |
|---|---|
AtmosphereResourceImpl(AtmosphereServlet.AtmosphereConfig config,
Broadcaster broadcaster,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse response,
CometSupport cometSupport,
AtmosphereHandler atmosphereHandler)
Create an AtmosphereResource. |
|
| Method Summary | |
|---|---|
AtmosphereServlet.Action |
action()
Return the AtmosphereServlet.Action which represent the state of the response,
e.g. |
void |
addEventListener(AtmosphereResourceEventListener e)
Add a AtmosphereResourceEventListener. |
ConcurrentLinkedQueue<AtmosphereResourceEventListener> |
atmosphereResourceEventListener()
|
void |
cancel()
|
static String |
createStreamingPadding(String padding)
Output message when Atmosphere suspend a connection. |
boolean |
equals(Object o)
|
AtmosphereServlet.AtmosphereConfig |
getAtmosphereConfig()
Return the AtmosphereServlet.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)
|
javax.servlet.http.HttpServletRequest |
getRequest()
Return the underlying |
javax.servlet.http.HttpServletRequest |
getRequest(boolean enforceScope)
|
javax.servlet.http.HttpServletResponse |
getResponse()
Return the underlying |
javax.servlet.http.HttpServletResponse |
getResponse(boolean enforceScope)
|
Serializer |
getSerializer()
Get the Serializer or null if not defined. |
int |
hashCode()
|
protected boolean |
isCancelled()
|
boolean |
isInScope()
Is the HttpServletRequest still valid. |
protected boolean |
isResumed()
|
void |
notifyListeners()
Notify AtmosphereResourceEventListener. |
void |
notifyListeners(AtmosphereResourceEvent event)
Notify AtmosphereResourceEventListener. |
void |
onThrowable(Throwable t)
Notify AtmosphereResourceEventListener an unexpected exception occured.\ |
void |
removeEventListener(AtmosphereResourceEventListener e)
Add a AtmosphereResourceEventListener. |
void |
removeEventListeners()
Remove all AtmosphereResourceEventListener. |
void |
resume()
Complete the HttpServletResponse and finish/commit it. |
void |
setBroadcaster(Broadcaster broadcaster)
Set the current Broadcaster. |
void |
setIsInScope(boolean isInScope)
Protect the object for being used after it got cancelled. |
void |
setSerializer(Serializer s)
Set the Serializer used to write broadcasted object. |
void |
suspend()
Suspend the HttpServletResponse indefinitely. |
void |
suspend(long timeout)
Suspend the HttpServletResponse. |
void |
suspend(long timeout,
boolean flushComment)
Suspend the HttpServletResponse. |
void |
suspend(long timeout,
TimeUnit timeunit)
Suspend the HttpServletResponse. |
void |
suspend(long timeout,
TimeUnit timeunit,
boolean flushComment)
Suspend the HttpServletResponse. |
String |
toString()
|
void |
write(OutputStream os,
Object o)
Write the broadcasted object using the OutputStream. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String PRE_SUSPEND
public static final String SKIP_BROADCASTER_CREATION
public static final String METEOR
protected final AtmosphereServlet.Action action
protected Broadcaster broadcaster
protected final CometSupport cometSupport
| Constructor Detail |
|---|
public AtmosphereResourceImpl(AtmosphereServlet.AtmosphereConfig config,
Broadcaster broadcaster,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse response,
CometSupport cometSupport,
AtmosphereHandler atmosphereHandler)
AtmosphereResource.
config - The AtmosphereServlet.AtmosphereConfigbroadcaster - The Broadcaster.req - The HttpServletRequestresponse - The HttpServletResponsecometSupport - The CometSupportatmosphereHandler - The AtmosphereHandler| Method Detail |
|---|
public AtmosphereResourceEventImpl getAtmosphereResourceEvent()
AtmosphereResourceEvent.
getAtmosphereResourceEvent in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>public AtmosphereHandler getAtmosphereHandler()
AtmosphereHandler associated with this resource.
getAtmosphereHandler in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>AtmosphereHandler associated with this resource.public void resume()
HttpServletResponse and finish/commit it. If the
HttpServletResponse is in the process of being resumed, invoking
that method has no effect.
resume in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>public void suspend()
HttpServletResponse indefinitely.
Suspending a HttpServletResponse 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 AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>public void suspend(long timeout)
HttpServletResponse. Suspending a HttpServletResponse 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 ServletResponse.getWriter() will be used. You can change that
behavior by setting a request attribute named org.atmosphere.useStream to
so the framework will use ServletResponse.getOutputStream()
suspend in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>timeout - The maximum amount of time, in milliseconds,
a HttpServletResponse can be suspended. When the timeout expires (because
nothing has been written or because the AtmosphereResource.resume()
, the HttpServletResponse will be automatically
resumed and commited. Usage of any methods of a HttpServletResponse that
times out will throw an IllegalStateException.
public void suspend(long timeout,
TimeUnit timeunit)
HttpServletResponse. Suspending a HttpServletResponse 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 ServletResponse.getWriter() will be used. You can change that
behavior by setting a request attribute named org.atmosphere.useStream to
so the framework will use ServletResponse.getOutputStream()
suspend in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>timeout - The maximum amount of time,
a HttpServletResponse can be suspended. When the timeout expires (because
nothing has been written or because the AtmosphereResource.resume()
, the HttpServletResponse will be automatically
resumed and commited. Usage of any methods of a HttpServletResponse that
times out will throw an IllegalStateException.timeunit - The time unit of the timeout value
public void suspend(long timeout,
TimeUnit timeunit,
boolean flushComment)
HttpServletResponse. Suspending a HttpServletResponse 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 ServletResponse.getWriter() will be used. You can change that
behavior by setting a request attribute named org.atmosphere.useStream to
so the framework will use ServletResponse.getOutputStream()
suspend in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>timeout - The maximum amount of time, in milliseconds,
a HttpServletResponse can be suspended. When the timeout expires (because
nothing has been written or because the AtmosphereResource.resume()
, the HttpServletResponse will be automatically
resumed and commited. Usage of any methods of a HttpServletResponse 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 void suspend(long timeout,
boolean flushComment)
AtmosphereResourceHttpServletResponse. Suspending a HttpServletResponse 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 ServletResponse.getWriter() will be used. You can change that
behavior by setting a request attribute named org.atmosphere.useStream to
so the framework will use ServletResponse.getOutputStream()
suspend in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>timeout - The maximum amount of time, in milliseconds,
a HttpServletResponse can be suspended. When the timeout expires (because
nothing has been written or because the AtmosphereResource.resume()
, the HttpServletResponse will be automatically
resumed and commited. Usage of any methods of a HttpServletResponse 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 javax.servlet.http.HttpServletRequest getRequest(boolean enforceScope)
public javax.servlet.http.HttpServletResponse getResponse(boolean enforceScope)
public javax.servlet.http.HttpServletRequest getRequest()
getRequest in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>public javax.servlet.http.HttpServletResponse getResponse()
getResponse in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>public Broadcaster getBroadcaster()
Broadcaster
getBroadcaster in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>Broadcasterprotected Broadcaster getBroadcaster(boolean autoCreate)
public void 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 AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>public AtmosphereServlet.AtmosphereConfig getAtmosphereConfig()
AtmosphereServlet.AtmosphereConfig
getAtmosphereConfig in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>AtmosphereServlet.AtmosphereConfigpublic AtmosphereServlet.Action action()
AtmosphereServlet.Action which represent the state of the response,
e.g. suspended, resumed or timedout.
AtmosphereServlet.Actionpublic void setIsInScope(boolean isInScope)
isInScope - public boolean isInScope()
HttpServletRequest still valid.
HttpServletRequest still validpublic void setSerializer(Serializer s)
Serializer used to write broadcasted object.
setSerializer in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>s - protected boolean isResumed()
protected boolean isCancelled()
public void write(OutputStream os,
Object o)
throws IOException
OutputStream. If a
Serializer is defined, the operation will be delagated to it. If
not, the
write in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>os - an OutputStreamo - an Object
IOExceptionpublic Serializer getSerializer()
Serializer or null if not defined.
getSerializer in interface AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>Serializer or null if not defined.public static String createStreamingPadding(String padding)
public void addEventListener(AtmosphereResourceEventListener e)
AtmosphereResourceEventListener.
addEventListener in interface AtmosphereEventLifecyclee - an instance of AtmosphereResourceEventListenerpublic void removeEventListener(AtmosphereResourceEventListener e)
AtmosphereResourceEventListener.
removeEventListener in interface AtmosphereEventLifecyclee - an instance of AtmosphereResourceEventListenerpublic void removeEventListeners()
AtmosphereResourceEventListener.
removeEventListeners in interface AtmosphereEventLifecyclepublic void notifyListeners()
AtmosphereResourceEventListener.
notifyListeners in interface AtmosphereEventLifecyclepublic void notifyListeners(AtmosphereResourceEvent event)
AtmosphereResourceEventListener.
notifyListeners in interface AtmosphereEventLifecycleevent - an instance of AtmosphereResourceEventpublic void onThrowable(Throwable t)
AtmosphereResourceEventListener an unexpected exception occured.\
public ConcurrentLinkedQueue<AtmosphereResourceEventListener> atmosphereResourceEventListener()
public void cancel()
throws IOException
IOExceptionpublic boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||