use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.
the class AtmosphereFramework method servletConfig.
protected void servletConfig(final ServletConfig sc, boolean wrap) {
if (wrap) {
String value = sc.getServletContext().getInitParameter(USE_SERVLET_CONTEXT_PARAMETERS);
final boolean useServletContextParameters = value != null && Boolean.valueOf(value);
servletConfig = new ServletConfig() {
AtomicBoolean done = new AtomicBoolean();
public String getServletName() {
return sc.getServletName();
}
public ServletContext getServletContext() {
return sc.getServletContext();
}
public String getInitParameter(String name) {
String param = initParams.get(name);
if (param == null) {
param = sc.getInitParameter(name);
if (param == null && useServletContextParameters) {
param = sc.getServletContext().getInitParameter(name);
}
}
return param;
}
public Enumeration<String> getInitParameterNames() {
if (!done.getAndSet(true)) {
Enumeration en = sc.getInitParameterNames();
if (en != null) {
while (en.hasMoreElements()) {
String name = (String) en.nextElement();
if (!initParams.containsKey(name)) {
initParams.put(name, sc.getInitParameter(name));
}
}
}
}
return Collections.enumeration(initParams.keySet());
}
};
} else {
servletConfig = sc;
}
}
use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.
the class WebSocketFactoryTest method create.
@BeforeMethod
public void create() throws Throwable {
framework = new AtmosphereFramework();
framework.setAsyncSupport(mock(AsyncSupport.class));
framework.addAnnotationPackage(WebSocketFactoryTest.class);
framework.init(new ServletConfig() {
@Override
public String getServletName() {
return "void";
}
@Override
public ServletContext getServletContext() {
return mock(ServletContext.class);
}
@Override
public String getInitParameter(String name) {
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return null;
}
});
}
use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.
the class WebSocketProcessorTest method create.
@BeforeMethod
public void create() throws Throwable {
framework = new AtmosphereFramework();
framework.setAsyncSupport(new AsynchronousProcessor(framework.getAtmosphereConfig()) {
@Override
public Action service(AtmosphereRequest req, AtmosphereResponse res) throws IOException, ServletException {
return action(req, res);
}
});
framework.addInitParameter(RECYCLE_ATMOSPHERE_REQUEST_RESPONSE, "false");
framework.init(new ServletConfig() {
@Override
public String getServletName() {
return "void";
}
@Override
public ServletContext getServletContext() {
return mock(ServletContext.class);
}
@Override
public String getInitParameter(String name) {
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return null;
}
});
}
use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.
the class CookieTest method create.
@BeforeMethod
public void create() throws Throwable {
framework = new AtmosphereFramework();
framework.setAsyncSupport(new BlockingIOCometSupport(framework.getAtmosphereConfig()));
framework.init(new ServletConfig() {
@Override
public String getServletName() {
return "void";
}
@Override
public ServletContext getServletContext() {
return mock(ServletContext.class);
}
@Override
public String getInitParameter(String name) {
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return null;
}
});
}
use of javax.servlet.ServletConfig in project atmosphere by Atmosphere.
the class WebSocketStreamingHandlerTest method create.
@BeforeMethod
public void create() throws Throwable {
framework = new AtmosphereFramework();
framework.setAsyncSupport(new BlockingIOCometSupport(framework.getAtmosphereConfig()));
framework.addInitParameter(RECYCLE_ATMOSPHERE_REQUEST_RESPONSE, "false");
framework.init(new ServletConfig() {
@Override
public String getServletName() {
return "void";
}
@Override
public ServletContext getServletContext() {
return mock(ServletContext.class);
}
@Override
public String getInitParameter(String name) {
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return null;
}
});
}
Aggregations