|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.eclipse.jetty.websocket.WebSocketServlet
weblogic.servlet.http.AbstractAsyncServlet
org.atmosphere.cpr.AtmosphereServlet
public class AtmosphereServlet
The AtmosphereServlet acts as a dispatcher for AtmosphereHandler
defined in META-INF/atmosphere.xml, or if atmosphere.xml is missing, all classes
that implements AtmosphereHandler will be discovered and mapped using
the class's name.
Servlet can be defined inside an application's web.xml using the following:
<servlet>
<description>AtmosphereServlet</description>
<servlet-name>AtmosphereServlet</servlet-name>
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
<load-on-startup>0 </load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AtmosphereServlet</servlet-name>
<url-pattern>/Atmosphere </url-pattern>
</servlet-mapping>
You can force this Servlet to use native API of the Web Server instead of
the Servlet 3.0 Async API you are deploying on by adding
<init-param>
<param-name>org.atmosphere.useNative</param-name>
<param-value>true</param-value>
</init-param>
You can force this Servlet to use one Thread per connection instead of
native API of the Web Server you are deploying on by adding
<init-param>
<param-name>org.atmosphere.useBlocking</param-name>
<param-value>true</param-value>
</init-param>
You can also define Broadcasterby adding:
<init-param>
<param-name>org.atmosphere.cpr.broadcasterClass</param-name>
<param-value>class-name</param-value>
</init-param>
You can also for Atmosphere to use OutputStream for all write operations.
<init-param>
<param-name>org.atmosphere.useStream</param-name>
<param-value>true</param-value>
</init-param>
You can also configure BroadcasterCache that persist message when Browser is disconnected.
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>class-name</param-value>
</init-param>
You can also configure Atmosphere to use http session or not
<init-param>
<param-name>org.atmosphere.cpr.sessionSupport</param-name>
<param-value>false</param-value>
</init-param>
You can also configure BroadcastFilter that will be applied at all newly created Broadcaster
<init-param>
<param-name>org.atmosphere.cpr.broadcastFilterClasses</param-name>
<param-value>BroadcastFilter class name separated by coma</param-value>
</init-param>
The Atmosphere Framework can also be used as a Servlet Filter (AtmosphereFilter).
If you are planning to use JSP, Servlet or JSF, you can instead use the
MeteorServlet, which allow the use of Meteor inside those
components.
| Nested Class Summary | |
|---|---|
static class |
AtmosphereServlet.Action
Simple class/struck that hold the current state. |
class |
AtmosphereServlet.AtmosphereConfig
|
static class |
AtmosphereServlet.AtmosphereHandlerWrapper
|
| Constructor Summary | |
|---|---|
AtmosphereServlet()
Create an Atmosphere Servlet. |
|
AtmosphereServlet(boolean isFilter)
Create an Atmosphere Servlet. |
|
| Method Summary | |
|---|---|
void |
addAtmosphereHandler(String mapping,
AtmosphereHandler h)
Add an AtmosphereHandler serviced by the Servlet
This API is exposed to allow embedding an Atmosphere application. |
void |
addAtmosphereHandler(String mapping,
AtmosphereHandler h,
Broadcaster broadcaster)
Add an AtmosphereHandler serviced by the Servlet
This API is exposed to allow embedding an Atmosphere application. |
void |
addAtmosphereHandler(String mapping,
AtmosphereHandler h,
String broadcasterId)
Add an AtmosphereHandler serviced by the Servlet
This API is exposed to allow embedding an Atmosphere application. |
void |
addInitParameter(String name,
String value)
Add init-param like if they were defined in web.xml |
protected void |
autoDetectAtmosphereHandlers(javax.servlet.ServletContext sc,
URLClassLoader c)
Auto detect instance of AtmosphereHandler in case META-INF/atmosphere.xml
is missing. |
protected void |
autoDetectContainer()
Auto detect the underlying Servlet Container we are running on. |
protected void |
configureBroadcaster()
|
protected CometSupportResolver |
createCometSupportResolver()
Returns an instance of CometSupportResolver CometSupportResolver |
void |
destroy()
|
protected boolean |
detectSupportedFramework(javax.servlet.ServletConfig sc)
Auto-detect Jersey when no atmosphere.xml file are specified. |
protected AtmosphereServlet.Action |
doCometSupport(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Invoke the proprietary CometSupport |
void |
doDelete(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Delegate the request processing to an instance of CometSupport |
void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Delegate the request processing to an instance of CometSupport |
void |
doHead(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Delegate the request processing to an instance of CometSupport |
protected void |
doInitParams(javax.servlet.ServletConfig sc)
Read init param from web.xml and apply them. |
void |
doOptions(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Delegate the request processing to an instance of CometSupport |
void |
doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Delegate the request processing to an instance of CometSupport |
void |
doPut(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Delegate the request processing to an instance of CometSupport |
protected boolean |
doRequest(RequestResponseKey rrk)
Weblogic specific comet based implementation. |
protected void |
doResponse(RequestResponseKey rrk,
Object context)
Weblogic specific comet based implementation. |
protected void |
doTimeout(RequestResponseKey rrk)
Weblogic specific comet based implementation. |
void |
doTrace(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Delegate the request processing to an instance of CometSupport |
protected WebSocket |
doWebSocketConnect(javax.servlet.http.HttpServletRequest request,
String protocol)
Jetty 7 and up WebSocket support. |
void |
event(CometEvent cometEvent)
Hack to support Tomcat AIO like other WebServer. |
void |
event(HttpEvent httpEvent)
Hack to support JBossWeb AIO like other WebServer. |
AtmosphereServlet.AtmosphereConfig |
getAtmosphereConfig()
Return a configured instance of AtmosphereServlet.AtmosphereConfig |
String |
getBroadcasterCacheClassName()
Return the BroadcasterCache class name. |
static BroadcasterConfig |
getBroadcasterConfig()
Return the BroadcasterConfig used by this instance. |
BroadcasterFactory |
getBroadcasterFactory()
Get the BroadcasterFactory which is used by Atmosphere to construct
Broadcaster |
CometSupport |
getCometSupport()
Return the current CometSupport |
static String |
getDefaultBroadcasterClassName()
Return the default Broadcaster class name. |
protected void |
getFiles(File f)
Get the list of possible candidate to load as AtmosphereHandler |
void |
init(javax.servlet.ServletConfig sc)
Load the AtmosphereHandler associated with this AtmosphereServlet. |
boolean |
isUseStreamForFlushingComments()
true if Atmosphere uses ServletResponse.getOutputStream()
by default for write operation. |
protected void |
loadAtmosphereDotXml(InputStream stream,
URLClassLoader c)
Load AtmosphereHandler defined under META-INF/atmosphere.xml |
protected void |
loadConfiguration(javax.servlet.ServletConfig sc)
|
protected void |
readSystemProperties()
|
void |
removeAllAtmosphereHandler()
Remove all AtmosphereHandler |
void |
removeAllInitParams()
Remove all init parameters. |
boolean |
removeAtmosphereHandler(String mapping)
Remove an AtmosphereHandler |
protected void |
sessionSupport(boolean sessionSupport)
|
void |
setBroadcasterCacheClassName(String broadcasterCacheClassName)
Set the BroadcasterCache class name. |
AtmosphereServlet |
setBroadcasterFactory(BroadcasterFactory broadcasterFactory)
Set the BroadcasterFactory which is used by Atmosphere to construct
Broadcaster |
void |
setCometSupport(CometSupport cometSupport)
Set the CometSupport implementation. |
static void |
setDefaultBroadcasterClassName(String broadcasterClassName)
Set the default Broadcaster class name |
void |
setUseStreamForFlushingComments(boolean useStreamForFlushingComments)
Set to true so Atmosphere uses ServletResponse.getOutputStream()
by default for write operation. |
| Methods inherited from class weblogic.servlet.http.AbstractAsyncServlet |
|---|
notify |
| Methods inherited from class org.eclipse.jetty.websocket.WebSocketServlet |
|---|
checkOrigin, init, service |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
getLastModified, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.servlet.Servlet |
|---|
getServletConfig, getServletInfo, service |
| Field Detail |
|---|
public static final String JERSEY_BROADCASTER
public static final String JERSEY_CONTAINER
public static final String GAE_BROADCASTER
public static final String PROPERTY_SERVLET_MAPPING
public static final String PROPERTY_BLOCKING_COMETSUPPORT
public static final String PROPERTY_NATIVE_COMETSUPPORT
public static final String WEBSOCKET_SUPPORT
public static final String PROPERTY_USE_STREAM
public static final String BROADCASTER_FACTORY
public static final String BROADCASTER_CLASS
public static final String BROADCASTER_CACHE
public static final String PROPERTY_COMET_SUPPORT
public static final String PROPERTY_SESSION_SUPPORT
public static final String PRIMEFACES_SERVLET
public static final String DISABLE_ONSTATE_EVENT
public static final String WEB_INF
public static final String RESUME_ON_BROADCAST
public static final String ATMOSPHERE_SERVLET
public static final String ATMOSPHERE_RESOURCE
public static final String SUPPORT_SESSION
public static final String ATMOSPHERE_HANDLER
public static final String WEBSOCKET_ATMOSPHEREHANDLER
public static final Logger logger
public static final String RESUME_AND_KEEPALIVE
public static final String RESUMED_ON_TIMEOUT
public static final String DEFAULT_NAMED_DISPATCHER
public static final String BROADCAST_FILTER_CLASSES
protected final ArrayList<String> possibleAtmosphereHandlersCandidate
protected final HashMap<String,String> initParams
protected final AtmosphereServlet.AtmosphereConfig config
protected final AtomicBoolean isCometSupportConfigured
protected final boolean isFilter
protected boolean useNativeImplementation
protected boolean useBlockingImplementation
protected boolean useStreamForFlushingComments
protected CometSupport cometSupport
protected static String broadcasterClassName
protected boolean isCometSupportSpecified
protected boolean isBroadcasterSpecified
protected boolean isSessionSupportSpecified
| Constructor Detail |
|---|
public AtmosphereServlet()
public AtmosphereServlet(boolean isFilter)
isFilter - true if this instance is used as an AtmosphereFilter| Method Detail |
|---|
public AtmosphereServlet.AtmosphereConfig getAtmosphereConfig()
AtmosphereServlet.AtmosphereConfig
AtmosphereServlet.AtmosphereConfig
public void addAtmosphereHandler(String mapping,
AtmosphereHandler h)
AtmosphereHandler serviced by the Servlet
This API is exposed to allow embedding an Atmosphere application.
mapping - The servlet mapping (servlet path)h - implementation of an AtmosphereHandler
public void addAtmosphereHandler(String mapping,
AtmosphereHandler h,
String broadcasterId)
AtmosphereHandler serviced by the Servlet
This API is exposed to allow embedding an Atmosphere application.
mapping - The servlet mapping (servlet path)h - implementation of an AtmosphereHandlerbroadcasterId - The Broadcaster.getID() value.
public void addAtmosphereHandler(String mapping,
AtmosphereHandler h,
Broadcaster broadcaster)
AtmosphereHandler serviced by the Servlet
This API is exposed to allow embedding an Atmosphere application.
mapping - The servlet mapping (servlet path)h - implementation of an AtmosphereHandlerbroadcaster - The Broadcaster associated with AtmosphereHandler.public boolean removeAtmosphereHandler(String mapping)
AtmosphereHandler
mapping - the mapping used when invoking addAtmosphereHandler(String, AtmosphereHandler);
public void removeAllAtmosphereHandler()
AtmosphereHandler
public void removeAllInitParams()
public void addInitParameter(String name,
String value)
name - The namevalue - The valueprotected void readSystemProperties()
public void init(javax.servlet.ServletConfig sc)
throws javax.servlet.ServletException
AtmosphereHandler associated with this AtmosphereServlet.
init in interface javax.servlet.Servletinit in class javax.servlet.GenericServletsc - the ServletContext
javax.servlet.ServletException
protected void configureBroadcaster()
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
ClassNotFoundException
InstantiationException
IllegalAccessExceptionprotected void doInitParams(javax.servlet.ServletConfig sc)
sc - ServletConfig
protected void loadConfiguration(javax.servlet.ServletConfig sc)
throws javax.servlet.ServletException
javax.servlet.ServletException
protected boolean detectSupportedFramework(javax.servlet.ServletConfig sc)
throws ClassNotFoundException,
IllegalAccessException,
InstantiationException,
NoSuchMethodException,
InvocationTargetException
sc - ServletConfig
ClassNotFoundException
IllegalAccessException
InstantiationException
NoSuchMethodException
InvocationTargetExceptionprotected void sessionSupport(boolean sessionSupport)
public void destroy()
destroy in interface javax.servlet.Servletdestroy in class javax.servlet.GenericServlet
protected void loadAtmosphereDotXml(InputStream stream,
URLClassLoader c)
throws IOException,
javax.servlet.ServletException
stream - The input stream we read from.c - The classloader
IOException
javax.servlet.ServletExceptionpublic void setCometSupport(CometSupport cometSupport)
CometSupport implementation. Make sure you don't set
an implementation that only works on some Container. See BlockingIOCometSupport
for an example.
cometSupport - public CometSupport getCometSupport()
CometSupport
CometSupportprotected CometSupportResolver createCometSupportResolver()
CometSupportResolver
protected void autoDetectContainer()
protected void autoDetectAtmosphereHandlers(javax.servlet.ServletContext sc,
URLClassLoader c)
throws MalformedURLException,
URISyntaxException
AtmosphereHandler in case META-INF/atmosphere.xml
is missing.
sc - ServletContextc - URLClassLoader to load the class.
MalformedURLException
URISyntaxExceptionprotected void getFiles(File f)
AtmosphereHandler
f - the real path File
public void doHead(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws IOException,
javax.servlet.ServletException
CometSupport
doHead in class javax.servlet.http.HttpServletreq - the HttpServletRequestres - the HttpServletResponse
IOException
javax.servlet.ServletException
public void doOptions(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws IOException,
javax.servlet.ServletException
CometSupport
doOptions in class javax.servlet.http.HttpServletreq - the HttpServletRequestres - the HttpServletResponse
IOException
javax.servlet.ServletException
public void doTrace(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws IOException,
javax.servlet.ServletException
CometSupport
doTrace in class javax.servlet.http.HttpServletreq - the HttpServletRequestres - the HttpServletResponse
IOException
javax.servlet.ServletException
public void doDelete(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws IOException,
javax.servlet.ServletException
CometSupport
doDelete in class javax.servlet.http.HttpServletreq - the HttpServletRequestres - the HttpServletResponse
IOException
javax.servlet.ServletException
public void doPut(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws IOException,
javax.servlet.ServletException
CometSupport
doPut in class javax.servlet.http.HttpServletreq - the HttpServletRequestres - the HttpServletResponse
IOException
javax.servlet.ServletException
public void doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws IOException,
javax.servlet.ServletException
CometSupport
doGet in class javax.servlet.http.HttpServletreq - the HttpServletRequestres - the HttpServletResponse
IOException
javax.servlet.ServletException
public void doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws IOException,
javax.servlet.ServletException
CometSupport
doPost in class javax.servlet.http.HttpServletreq - the HttpServletRequestres - the HttpServletResponse
IOException
javax.servlet.ServletException
protected AtmosphereServlet.Action doCometSupport(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws IOException,
javax.servlet.ServletException
CometSupport
req - res -
AtmosphereServlet.Action
IOException
javax.servlet.ServletException
public void event(CometEvent cometEvent)
throws IOException,
javax.servlet.ServletException
Servlet implements the interface
CometProcessor without invoking Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
event in interface CometProcessorevent in interface HttpEventServletcometEvent - the CometEvent
IOException
javax.servlet.ServletException
public void event(HttpEvent httpEvent)
throws IOException,
javax.servlet.ServletException
Servlet implements the interface
HttpEventServlet without invoking Servlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
httpEvent - the CometEvent
IOException
javax.servlet.ServletException
protected boolean doRequest(RequestResponseKey rrk)
throws IOException,
javax.servlet.ServletException
doRequest in class AbstractAsyncServletrrk -
IOException
javax.servlet.ServletException
protected void doResponse(RequestResponseKey rrk,
Object context)
throws IOException,
javax.servlet.ServletException
doResponse in class AbstractAsyncServletrrk -
IOException
javax.servlet.ServletException
protected void doTimeout(RequestResponseKey rrk)
throws IOException,
javax.servlet.ServletException
doTimeout in class AbstractAsyncServletrrk -
IOException
javax.servlet.ServletExceptionpublic static String getDefaultBroadcasterClassName()
Broadcaster class name.
public static void setDefaultBroadcasterClassName(String broadcasterClassName)
Broadcaster class name
broadcasterClassName - the broadcasterClassName to setpublic boolean isUseStreamForFlushingComments()
ServletResponse.getOutputStream()
by default for write operation.
public void setUseStreamForFlushingComments(boolean useStreamForFlushingComments)
ServletResponse.getOutputStream()
by default for write operation. Default is false.
useStreamForFlushingComments - the useStreamForFlushingComments to setpublic BroadcasterFactory getBroadcasterFactory()
BroadcasterFactory which is used by Atmosphere to construct
Broadcaster
BroadcasterFactory
public AtmosphereServlet setBroadcasterFactory(BroadcasterFactory broadcasterFactory)
throws IllegalAccessException,
InstantiationException,
ClassNotFoundException
BroadcasterFactory which is used by Atmosphere to construct
Broadcaster
BroadcasterFactory
IllegalAccessException
InstantiationException
ClassNotFoundExceptionpublic static BroadcasterConfig getBroadcasterConfig()
BroadcasterConfig used by this instance.
BroadcasterConfigpublic String getBroadcasterCacheClassName()
BroadcasterCache class name.
BroadcasterCache class name.
public void setBroadcasterCacheClassName(String broadcasterCacheClassName)
throws IllegalAccessException,
InstantiationException,
ClassNotFoundException
BroadcasterCache class name.
broadcasterCacheClassName -
IllegalAccessException
InstantiationException
ClassNotFoundException
protected WebSocket doWebSocketConnect(javax.servlet.http.HttpServletRequest request,
String protocol)
doWebSocketConnect in class WebSocketServletrequest - protocol -
WebSocket}
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||