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 Object
implements AsyncSupport<AtmosphereResourceImpl>
Base class which implement the semantics of suspending and resuming of a Comet/WebSocket Request.
- Author:
- Jeanfrancois Arcand
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Actionprotected final AtmosphereConfigprotected static final Action -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidProcess anActionfrom anActionEventoperation like suspend, resume or timed out.protected booleanIsHttpSessiontimeout removal supportedcancelled(AtmosphereRequest req, AtmosphereResponse res) All proprietary Comet basedServletmust invoke the cancelled method when the underlying WebServer detect that the client closed the connection.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) Return the container's name.voidinit(javax.servlet.ServletConfig sc) Initialize the WebServer using theServletConfigprotected voidInvoke the associatedAtmosphereHandler.invokeInterceptors(List<AtmosphereInterceptor> c, AtmosphereResource r, int tracing) map(AtmosphereRequest req) Return theAtmosphereHandlermapped to the passed servlet-path.voidresumed(AtmosphereRequest request, AtmosphereResponse response) All proprietary Comet basedServletmust invoke the resume method when the Atmosphere's application decide to resume theAtmosphereResponse.protected voidshutdown()protected booleanIsHttpSessionsupportedbooleanReturn true if this implementation supports the websocket protocol.suspended(AtmosphereRequest request, AtmosphereResponse response) All proprietary Comet basedServletmust invoke the suspended method when the first request comes in.timedout(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, waitMethods inherited from interface org.atmosphere.cpr.AsyncSupport
service
-
Field Details
-
timedoutAction
-
cancelledAction
-
config
-
-
Constructor Details
-
AsynchronousProcessor
-
-
Method Details
-
init
public void init(javax.servlet.ServletConfig sc) throws javax.servlet.ServletException Description 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
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 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:
IOExceptionjavax.servlet.ServletException
-
shutdown
protected void shutdown() -
action
Description copied from interface:AsyncSupportProcess anActionfrom anActionEventoperation like suspend, resume or timed out.- Specified by:
actionin interfaceAsyncSupport<AtmosphereResourceImpl>- Parameters:
r- An instance ofAction
-
complete
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
-
postInterceptors
-
map
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 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:
IOExceptionjavax.servlet.ServletException
-
timedout
public Action timedout(AtmosphereRequest req, AtmosphereResponse res) throws 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:
IOExceptionjavax.servlet.ServletException
-
completeLifecycle
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
Invoke the associatedAtmosphereHandler. This method must be synchronized on an AtmosphereResource.- Parameters:
r- aAtmosphereResourceImpl
-
cancelled
public Action cancelled(AtmosphereRequest req, AtmosphereResponse res) throws 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:
IOExceptionjavax.servlet.ServletException
-
endRequest
-
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
-