public class VibeAtmosphereServlet extends AtmosphereServlet
AtmosphereResource into ServerHttpExchange
and ServerWebSocket. You need to configure this servlet and provide
your action to receive ServerHttpExchange and ServerWebSocket
by overriding httpAction() and
wsAction() like the following usage. When you configure
servlet, you must set asyncSupported to
true and set a init param,
org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults
, to true.
ServletRegistration.Dynamic reg = context.addServlet(VibeAtmosphereServlet.class.getName(), new VibeAtmosphereServlet() {
@Override
protected Action<ServerHttpExchange> httpAction() {
return server.httpAction();
}
@Override
protected Action<ServerWebSocket> wsAction() {
return server.wsAction();
}
});
reg.setAsyncSupported(true);
reg.setInitParameter(ApplicationConfig.DISABLE_ATMOSPHEREINTERCEPTOR, Boolean.TRUE.toString())
reg.addMapping("/vibe");
With CDI, the following usage is also available.
@WebServlet(value = "/vibe", asyncSupported = true, initParams = { @WebInitParam(name = "org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults", value = "true") })
public class MyVibeAtmosphereServlet extends VibeAtmosphereServlet {
@Inject
private Server server;
@Override
protected Action<ServerHttpExchange> httpAction() {
return server.httpAction();
}
@Override
protected Action<ServerWebSocket> wsAction() {
return server.wsAction();
}
}
autoDetectHandlers, framework, isFilter, logger| Constructor and Description |
|---|
VibeAtmosphereServlet() |
| Modifier and Type | Method and Description |
|---|---|
protected Action<ServerHttpExchange> |
httpAction()
An
Action to consume ServerHttpExchange. |
void |
init(javax.servlet.ServletConfig sc) |
protected boolean |
isWebSocketResource(AtmosphereResource resource)
Does the given
AtmosphereResource represent WebSocket resource? |
protected Action<ServerWebSocket> |
wsAction()
An
Action to consume ServerWebSocket. |
configureFramework, destroy, doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, framework, newAtmosphereFrameworkpublic void init(javax.servlet.ServletConfig sc)
throws javax.servlet.ServletException
init in interface javax.servlet.Servletinit in class AtmosphereServletjavax.servlet.ServletExceptionprotected boolean isWebSocketResource(AtmosphereResource resource)
AtmosphereResource represent WebSocket resource?protected Action<ServerHttpExchange> httpAction()
Action to consume ServerHttpExchange. By default, it
throws IllegalStateException so you should provide your action by
overriding it.protected Action<ServerWebSocket> wsAction()
Action to consume ServerWebSocket. By default, it
throws IllegalStateException so you should provide your action by
overriding it.Copyright 2014, The Vibe Project