Package org.atmosphere.cpr
Class AsynchronousProcessor
- java.lang.Object
-
- org.atmosphere.cpr.AsynchronousProcessor
-
- All Implemented Interfaces:
AsyncSupport<AtmosphereResourceImpl>
- Direct Known Subclasses:
BlockingIOCometSupport,GlassFishv2CometSupport,Grizzly2CometSupport,GrizzlyCometSupport,JBossWebCometSupport,Jetty7CometSupport,JettyCometSupport,NettyCometSupport,Servlet30CometSupport,Tomcat7CometSupport,TomcatCometSupport
public abstract class AsynchronousProcessor extends java.lang.Object implements AsyncSupport<AtmosphereResourceImpl>
Base class which implement the semantics of suspending and resuming of a Comet/WebSocket Request.- Author:
- Jeanfrancois Arcand
-
-
Field Summary
Fields Modifier and Type Field Description protected static ActioncancelledActionprotected AtmosphereConfigconfigprotected static ActiontimedoutAction
-
Constructor Summary
Constructors Constructor Description AsynchronousProcessor(AtmosphereConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaction(AtmosphereResourceImpl r)Process anActionfrom anActionEventoperation like suspend, resume or timed out.protected booleanallowSessionTimeoutRemoval()IsHttpSessiontimeout removal supportedActioncancelled(AtmosphereRequest req, AtmosphereResponse res)All proprietary Comet basedServletmust invoke the cancelled method when the underlying WebServer detect that the client closed the connection.AsyncSupport<AtmosphereResourceImpl>complete(AtmosphereResourceImpl r)Complete and close the connection associated with an implementation ofAtmosphereResourcebooleancompleteLifecycle(AtmosphereResource r, boolean cancelled)Cancel or times out anAtmosphereResourceby invoking it's associatedAtmosphereHandler.onStateChange(AtmosphereResourceEvent)voidendRequest(AtmosphereResourceImpl r, boolean cancel)java.lang.StringgetContainerName()Return the container's name.voidinit(javax.servlet.ServletConfig sc)Initialize the WebServer using theServletConfigprotected voidinvokeAtmosphereHandler(AtmosphereResourceImpl r)Invoke the associatedAtmosphereHandler.ActioninvokeInterceptors(java.util.List<AtmosphereInterceptor> c, AtmosphereResource r, int tracing)protected AtmosphereFramework.AtmosphereHandlerWrappermap(AtmosphereRequest req)Return theAtmosphereHandlermapped to the passed servlet-path.voidpostInterceptors(java.util.List<AtmosphereInterceptor> c, AtmosphereResource r)Actionresumed(AtmosphereRequest request, AtmosphereResponse response)All proprietary Comet basedServletmust invoke the resume method when the Atmosphere's application decide to resume theAtmosphereResponse.protected voidshutdown()protected booleansupportSession()IsHttpSessionsupportedbooleansupportWebSocket()Return true if this implementation supports the websocket protocol.Actionsuspended(AtmosphereRequest request, AtmosphereResponse response)All proprietary Comet basedServletmust invoke the suspended method when the first request comes in.Actiontimedout(AtmosphereRequest req, AtmosphereResponse res)All proprietary Comet basedServletmust invoke the timedout method when the underlying WebServer time out theAtmosphereResponse.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.atmosphere.cpr.AsyncSupport
service
-
-
-
-
Field Detail
-
timedoutAction
protected static final Action timedoutAction
-
cancelledAction
protected static final Action cancelledAction
-
config
protected final AtmosphereConfig config
-
-
Constructor Detail
-
AsynchronousProcessor
public AsynchronousProcessor(AtmosphereConfig config)
-
-
Method Detail
-
init
public void init(javax.servlet.ServletConfig sc) throws javax.servlet.ServletExceptionDescription copied from interface:AsyncSupportInitialize the WebServer using theServletConfig- Specified by:
initin interfaceAsyncSupport<AtmosphereResourceImpl>- Parameters:
sc- theServletConfig- Throws:
javax.servlet.ServletException
-
supportSession
protected boolean supportSession()
IsHttpSessionsupported- Returns:
- true if supported
-
allowSessionTimeoutRemoval
protected boolean allowSessionTimeoutRemoval()
IsHttpSessiontimeout removal supported- Returns:
- true if supported
-
getContainerName
public java.lang.String getContainerName()
Return the container's name.- Specified by:
getContainerNamein interfaceAsyncSupport<AtmosphereResourceImpl>- Returns:
- the name of the Java Web Server.
-
suspended
public Action suspended(AtmosphereRequest request, AtmosphereResponse response) throws java.io.IOException, javax.servlet.ServletException
All proprietary Comet basedServletmust invoke the suspended method when the first request comes in. The returned value, of typeAction, tells the proprietary CometServletto suspended or not the currentAtmosphereResponse.- Parameters:
request- theAtmosphereRequestresponse- theAtmosphereResponse- Returns:
- action the Action operation.
- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
shutdown
protected void shutdown()
-
action
public void action(AtmosphereResourceImpl r)
Description copied from interface:AsyncSupportProcess anActionfrom anActionEventoperation like suspend, resume or timed out.- Specified by:
actionin interfaceAsyncSupport<AtmosphereResourceImpl>- Parameters:
r- An instance ofAction
-
complete
public AsyncSupport<AtmosphereResourceImpl> complete(AtmosphereResourceImpl r)
Description copied from interface:AsyncSupportComplete and close the connection associated with an implementation ofAtmosphereResource- Specified by:
completein interfaceAsyncSupport<AtmosphereResourceImpl>- Parameters:
r-AtmosphereResource- Returns:
- this
-
invokeInterceptors
public Action invokeInterceptors(java.util.List<AtmosphereInterceptor> c, AtmosphereResource r, int tracing)
-
postInterceptors
public void postInterceptors(java.util.List<AtmosphereInterceptor> c, AtmosphereResource r)
-
map
protected AtmosphereFramework.AtmosphereHandlerWrapper map(AtmosphereRequest req)
Return theAtmosphereHandlermapped to the passed servlet-path.- Parameters:
req- theAtmosphereResponse- Returns:
- the
AtmosphereHandlermapped to the passed servlet-path.
-
resumed
public Action resumed(AtmosphereRequest request, AtmosphereResponse response) throws java.io.IOException, javax.servlet.ServletException
All proprietary Comet basedServletmust invoke the resume method when the Atmosphere's application decide to resume theAtmosphereResponse. The returned value, of typeAction, tells the proprietary CometServletto resume (again), suspended or do nothing with the currentAtmosphereResponse.- Parameters:
request- theAtmosphereRequestresponse- theAtmosphereResponse- Returns:
- action the Action operation.
- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
timedout
public Action timedout(AtmosphereRequest req, AtmosphereResponse res) throws java.io.IOException, javax.servlet.ServletException
All proprietary Comet basedServletmust invoke the timedout method when the underlying WebServer time out theAtmosphereResponse. The returned value, of typeAction, tells the proprietary CometServletto resume (again), suspended or do nothing with the currentAtmosphereResponse.- Parameters:
req- theAtmosphereRequestres- theAtmosphereResponse- Returns:
- action the Action operation.
- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
completeLifecycle
public boolean completeLifecycle(AtmosphereResource r, boolean cancelled)
Cancel or times out anAtmosphereResourceby invoking it's associatedAtmosphereHandler.onStateChange(AtmosphereResourceEvent)- Parameters:
r- anAtmosphereResourcecancelled- true if cancelled, false if timedout- Returns:
- true if the operation was executed.
-
invokeAtmosphereHandler
protected void invokeAtmosphereHandler(AtmosphereResourceImpl r) throws java.io.IOException
Invoke the associatedAtmosphereHandler. This method must be synchronized on an AtmosphereResource.- Parameters:
r- aAtmosphereResourceImpl- Throws:
java.io.IOException
-
cancelled
public Action cancelled(AtmosphereRequest req, AtmosphereResponse res) throws java.io.IOException, javax.servlet.ServletException
All proprietary Comet basedServletmust invoke the cancelled method when the underlying WebServer detect that the client closed the connection.- Parameters:
req- theAtmosphereRequestres- theAtmosphereResponse- Returns:
- action the Action operation.
- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
endRequest
public void endRequest(AtmosphereResourceImpl r, boolean cancel)
-
supportWebSocket
public boolean supportWebSocket()
Description copied from interface:AsyncSupportReturn true if this implementation supports the websocket protocol.- Specified by:
supportWebSocketin interfaceAsyncSupport<AtmosphereResourceImpl>- Returns:
- true if supported
-
-