org.atmosphere.cpr
Class AsynchronousProcessor

java.lang.Object
  extended by org.atmosphere.cpr.AsynchronousProcessor
All Implemented Interfaces:
CometSupport<AtmosphereResourceImpl>
Direct Known Subclasses:
BlockingIOCometSupport, GlassFishv2CometSupport, GrizzlyCometSupport, JBossWebCometSupport, Jetty7CometSupport, JettyCometSupport, Servlet30CometSupport, Tomcat7CometSupport, TomcatCometSupport, WebLogicCometSupport

public abstract class AsynchronousProcessor
extends Object
implements CometSupport<AtmosphereResourceImpl>

Base class which implement the semantics of suspending and resuming of a Comet Request.

Author:
Jeanfrancois Arcand

Field Summary
protected  ConcurrentHashMap<javax.servlet.http.HttpServletRequest,AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>> aliveRequests
           
protected static AtmosphereServlet.Action cancelledAction
           
protected  AtmosphereServlet.AtmosphereConfig config
           
protected static AtmosphereServlet.Action timedoutAction
           
 
Constructor Summary
AsynchronousProcessor(AtmosphereServlet.AtmosphereConfig config)
           
 
Method Summary
 void action(AtmosphereResourceImpl r)
          Process an AtmosphereServlet.Action from an ActionEvent operation like suspend, resume or timed out.
 AtmosphereServlet.Action cancelled(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse 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  AtmosphereServlet.AtmosphereHandlerWrapper map(javax.servlet.http.HttpServletRequest req)
          Return the AtmosphereHandler mapped to the passed servlet-path.
 AtmosphereServlet.Action resumed(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          All proprietary Comet based Servlet must invoke the resume method when the Atmosphere's application decide to resume the HttpServletResponse.
protected  boolean supportSession()
          Is HttpSession supported
 boolean supportWebSocket()
          Return true if this implementation supports the websocket protocol.
 AtmosphereServlet.Action suspended(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          All proprietary Comet based Servlet must invoke the suspended method when the first request comes in.
 AtmosphereServlet.Action timedout(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          All proprietary Comet based Servlet must invoke the timedout method when the underlying WebServer time out the HttpServletResponse.
 
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.CometSupport
service
 

Field Detail

timedoutAction

protected static final AtmosphereServlet.Action timedoutAction

cancelledAction

protected static final AtmosphereServlet.Action cancelledAction

config

protected final AtmosphereServlet.AtmosphereConfig config

aliveRequests

protected final ConcurrentHashMap<javax.servlet.http.HttpServletRequest,AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>> aliveRequests
Constructor Detail

AsynchronousProcessor

public AsynchronousProcessor(AtmosphereServlet.AtmosphereConfig config)
Method Detail

init

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

Specified by:
init in interface CometSupport<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 CometSupport<AtmosphereResourceImpl>
Returns:
the name of the Java Web Server.

suspended

public AtmosphereServlet.Action suspended(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse 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 AtmosphereServlet.Action, tells the proprietary Comet Servlet to suspended or not the current HttpServletResponse.

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

action

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

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

map

protected AtmosphereServlet.AtmosphereHandlerWrapper map(javax.servlet.http.HttpServletRequest req)
                                                  throws javax.servlet.ServletException
Return the AtmosphereHandler mapped to the passed servlet-path.

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

resumed

public AtmosphereServlet.Action resumed(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse 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 HttpServletResponse. The returned value, of type AtmosphereServlet.Action, tells the proprietary Comet Servlet to resume (again), suspended or do nothing with the current HttpServletResponse.

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

timedout

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

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

destroyResource

public static void destroyResource(AtmosphereResource<?,?> r)

cancelled

public AtmosphereServlet.Action cancelled(javax.servlet.http.HttpServletRequest req,
                                          javax.servlet.http.HttpServletResponse 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 HttpServletRequest
res - the HttpServletResponse
Returns:
action the Action operation.
Throws:
IOException
javax.servlet.ServletException

supportWebSocket

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

Specified by:
supportWebSocket in interface CometSupport<AtmosphereResourceImpl>


Copyright © 2011. All Rights Reserved.