org.atmosphere.cpr
Class AsynchronousProcessor

java.lang.Object
  extended by org.atmosphere.cpr.AsynchronousProcessor
All Implemented Interfaces:
AsyncSupport<AtmosphereResourceImpl>
Direct Known Subclasses:
BlockingIOCometSupport, GlassFishv2CometSupport, 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

Nested Class Summary
static class AsynchronousProcessor.AsynchronousProcessorHook
          An Callback class that can be used by Framework integrator to handle the close/timedout/resume life cycle of an AtmosphereResource.
 
Field Summary
protected  ConcurrentHashMap<AtmosphereRequest,AtmosphereResource> aliveRequests
           
protected static Action cancelledAction
           
protected  AtmosphereConfig config
           
protected static Action timedoutAction
           
 
Constructor Summary
AsynchronousProcessor(AtmosphereConfig config)
           
 
Method Summary
 void action(AtmosphereResourceImpl r)
          Process an Action from an ActionEvent operation like suspend, resume or timed out.
 Action cancelled(AtmosphereRequest req, AtmosphereResponse res)
          All proprietary Comet based Servlet must invoke the cancelled method when the underlying WebServer detect that the client closed the connection.
static void destroyResource(AtmosphereResource r)
           
 String getContainerName()
          Return the container's name.
 void init(javax.servlet.ServletConfig sc)
          Initialize the WebServer using the ServletConfig
protected  AtmosphereFramework.AtmosphereHandlerWrapper map(AtmosphereRequest req)
          Return the AtmosphereHandler mapped to the passed servlet-path.
protected  AtmosphereFramework.AtmosphereHandlerWrapper map(String path)
           
 Action resumed(AtmosphereRequest request, AtmosphereResponse response)
          All proprietary Comet based Servlet must invoke the resume method when the Atmosphere's application decide to resume the AtmosphereResponse.
protected  void shutdown()
           
protected  boolean supportSession()
          Is HttpSession supported
 boolean supportWebSocket()
          Return true if this implementation supports the websocket protocol.
 Action suspended(AtmosphereRequest request, AtmosphereResponse response)
          All proprietary Comet based Servlet must invoke the suspended method when the first request comes in.
 Action timedout(AtmosphereRequest request, AtmosphereResponse response)
          All proprietary Comet based Servlet must invoke the timedout method when the underlying WebServer time out the AtmosphereResponse.
 
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

aliveRequests

protected final ConcurrentHashMap<AtmosphereRequest,AtmosphereResource> aliveRequests
Constructor Detail

AsynchronousProcessor

public AsynchronousProcessor(AtmosphereConfig config)
Method Detail

init

public void init(javax.servlet.ServletConfig sc)
          throws javax.servlet.ServletException
Description copied from interface: AsyncSupport
Initialize the WebServer using the ServletConfig

Specified by:
init in interface AsyncSupport<AtmosphereResourceImpl>
Parameters:
sc - the ServletConfig
Throws:
javax.servlet.ServletException

supportSession

protected boolean supportSession()
Is HttpSession supported

Returns:
true if supported

getContainerName

public String getContainerName()
Return the container's name.

Specified by:
getContainerName in interface AsyncSupport<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 based Servlet must invoke the suspended method when the first request comes in. The returned value, of type Action, tells the proprietary Comet Servlet to suspended or not the current AtmosphereResponse.

Parameters:
request - the AtmosphereRequest
response - the AtmosphereResponse
Returns:
action the Action operation.
Throws:
IOException
javax.servlet.ServletException

action

public void action(AtmosphereResourceImpl r)
Process an Action from an ActionEvent operation like suspend, resume or timed out.

Specified by:
action in interface AsyncSupport<AtmosphereResourceImpl>
Parameters:
r - An instance of Action

map

protected AtmosphereFramework.AtmosphereHandlerWrapper map(String path)

map

protected AtmosphereFramework.AtmosphereHandlerWrapper map(AtmosphereRequest req)
                                                    throws javax.servlet.ServletException
Return the AtmosphereHandler mapped to the passed servlet-path.

Parameters:
req - the AtmosphereResponse
Returns:
the AtmosphereHandler mapped to the passed servlet-path.
Throws:
javax.servlet.ServletException

resumed

public Action resumed(AtmosphereRequest request,
                      AtmosphereResponse response)
               throws IOException,
                      javax.servlet.ServletException
All proprietary Comet based Servlet must invoke the resume method when the Atmosphere's application decide to resume the AtmosphereResponse. The returned value, of type Action, tells the proprietary Comet Servlet to resume (again), suspended or do nothing with the current AtmosphereResponse.

Parameters:
request - the AtmosphereRequest
response - the AtmosphereResponse
Returns:
action the Action operation.
Throws:
IOException
javax.servlet.ServletException

timedout

public Action timedout(AtmosphereRequest request,
                       AtmosphereResponse response)
                throws IOException,
                       javax.servlet.ServletException
All proprietary Comet based Servlet must invoke the timedout method when the underlying WebServer time out the AtmosphereResponse. The returned value, of type Action, tells the proprietary Comet Servlet to resume (again), suspended or do nothing with the current AtmosphereResponse.

Parameters:
request - the AtmosphereRequest
response - the AtmosphereResponse
Returns:
action the Action operation.
Throws:
IOException
javax.servlet.ServletException

destroyResource

public static void destroyResource(AtmosphereResource r)

cancelled

public Action cancelled(AtmosphereRequest req,
                        AtmosphereResponse res)
                 throws IOException,
                        javax.servlet.ServletException
All proprietary Comet based Servlet must invoke the cancelled method when the underlying WebServer detect that the client closed the connection.

Parameters:
req - the AtmosphereRequest
res - the AtmosphereResponse
Returns:
action the Action operation.
Throws:
IOException
javax.servlet.ServletException

shutdown

protected void shutdown()

supportWebSocket

public boolean supportWebSocket()
Description copied from interface: AsyncSupport
Return true if this implementation supports the websocket protocol. return true if supported

Specified by:
supportWebSocket in interface AsyncSupport<AtmosphereResourceImpl>


Copyright © 2012. All Rights Reserved.