org.atmosphere.cpr
Class AtmosphereEventImpl

java.lang.Object
  extended by org.atmosphere.cpr.AtmosphereEventImpl
All Implemented Interfaces:
AtmosphereEvent<HttpServletRequest,HttpServletResponse>

public class AtmosphereEventImpl
extends Object
implements AtmosphereEvent<HttpServletRequest,HttpServletResponse>

AtmosphereEvent implementation for supporting HttpServletRequest and HttpServletResponse.

Author:
Jeanfrancois Arcand

Field Summary
protected  AtmosphereServlet.Action action
           
protected  Broadcaster broadcaster
           
protected  Object message
           
protected  String webServerName
           
 
Constructor Summary
AtmosphereEventImpl(ServletContext servletContext, String webServerName, Broadcaster broadcaster, HttpServletRequest req, HttpServletResponse res)
          Create an AtmosphereEvent.
 
Method Summary
 Broadcaster getBroadcaster()
          Return the current Broadcaster
 Object getMessage()
          Return the object that were pass to Broadcaster.broadcast(java.lang.Object)
 HttpServletRequest getRequest()
          Return the underlying Request.
 HttpServletResponse getResponse()
          Return the underlying Response.
 ServletContext getServletContext()
          Return the ServletContext
 String getWebServerName()
          Return the WebServer we are running on.
 boolean isResuming()
          Return true if that AtmosphereEvent.resume() has been invoked
 boolean isSuspended()
          Return true if that AtmosphereEvent.suspend() has been invoked and set to true
protected  void reset(HttpServletRequest req, HttpServletResponse res)
           
 void resume()
          Complete the HttpServletResponse and finish/commit it.
 void setBroadcaster(Broadcaster broadcaster)
          Set the current Broadcaster
protected  void setMessage(Object message)
          Set the message broadacasted using Broadcaster.broadcast(java.lang.Object)
 void suspend()
          Suspend the HttpServletResponse indefinitely.
 void suspend(long timeout)
          Suspend the HttpServletResponse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

protected AtmosphereServlet.Action action

broadcaster

protected Broadcaster broadcaster

webServerName

protected String webServerName

message

protected Object message
Constructor Detail

AtmosphereEventImpl

public AtmosphereEventImpl(ServletContext servletContext,
                           String webServerName,
                           Broadcaster broadcaster,
                           HttpServletRequest req,
                           HttpServletResponse res)
Create an AtmosphereEvent.

Parameters:
webServerName - The WebServer we are running on top of.
broadcaster - The Broadcaster.
req - The HttpServletRequest
res - The HttpServletResponse
Method Detail

resume

public void resume()
Complete the HttpServletResponse and finish/commit it.

Specified by:
resume in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>

isResuming

public boolean isResuming()
Return true if that AtmosphereEvent.resume() has been invoked

Specified by:
isResuming in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>
Returns:
true if that AtmosphereEvent.resume() has been invoked and set to true

isSuspended

public boolean isSuspended()
Return true if that AtmosphereEvent.suspend() has been invoked and set to true

Specified by:
isSuspended in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>
Returns:
true if that AtmosphereEvent.suspend() has been invoked and set to true

suspend

public void suspend()
Suspend the 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.

Specified by:
suspend in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>

suspend

public void suspend(long timeout)
Suspend the HttpServletResponse. Suspending a HttpServletResponse will tell the underlying container to avoid recycling objects associated with the current instance, and also to avoid commiting response.

Specified by:
suspend in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>
Parameters:
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 AtmosphereEvent.resume() or AtmosphereEvent#cancel()), the HttpServletResponse will be automatically resumed and commited. Usage of any methods of a HttpServletResponse that times out will throw an IllegalStateException.

getRequest

public HttpServletRequest getRequest()
Return the underlying Request.

Specified by:
getRequest in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>
Returns:
E the underlying Request.

getResponse

public HttpServletResponse getResponse()
Return the underlying Response.

Specified by:
getResponse in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>
Returns:
F the underlying Response.

getBroadcaster

public Broadcaster getBroadcaster()
Return the current Broadcaster

Specified by:
getBroadcaster in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>

setBroadcaster

public void setBroadcaster(Broadcaster broadcaster)
Set the current Broadcaster

Specified by:
setBroadcaster in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>

reset

protected void reset(HttpServletRequest req,
                     HttpServletResponse res)

getWebServerName

public String getWebServerName()
Return the WebServer we are running on.

Specified by:
getWebServerName in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>
Returns:
Return the WebServer we are running on.

getMessage

public Object getMessage()
Return the object that were pass to Broadcaster.broadcast(java.lang.Object)

Specified by:
getMessage in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>
Returns:
the object that were pass to Broadcaster.broadcast(java.lang.Object)

setMessage

protected void setMessage(Object message)
Set the message broadacasted using Broadcaster.broadcast(java.lang.Object)

Parameters:
message - The message broadacasted using Broadcaster.broadcast(java.lang.Object)

getServletContext

public ServletContext getServletContext()
Return the ServletContext

Specified by:
getServletContext in interface AtmosphereEvent<HttpServletRequest,HttpServletResponse>
Returns:
the ServletContext


Copyright © 2009 SUN Microsystems. All Rights Reserved.