use of jakarta.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 = Boolean.parseBoolean(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<String> en = sc.getInitParameterNames();
if (en != null) {
while (en.hasMoreElements()) {
String name = en.nextElement();
if (!initParams.containsKey(name)) {
initParams.put(name, sc.getInitParameter(name));
}
}
}
}
return Collections.enumeration(initParams.keySet());
}
};
} else {
servletConfig = sc;
}
}
use of jakarta.servlet.ServletConfig in project atmosphere by Atmosphere.
the class SSEAtmosphereInterceptorTest method setup.
@BeforeMethod
public void setup() throws Exception {
framework = new AtmosphereFramework();
framework.setAsyncSupport(Mockito.mock(AsyncSupport.class));
framework.init(new ServletConfig() {
@Override
public String getServletName() {
return "void";
}
@Override
public ServletContext getServletContext() {
return Mockito.mock(ServletContext.class);
}
@Override
public String getInitParameter(String name) {
return null;
}
@Override
public Enumeration<String> getInitParameterNames() {
return null;
}
});
config = framework.getAtmosphereConfig();
}
use of jakarta.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 jakarta.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 jakarta.servlet.ServletConfig in project atmosphere by Atmosphere.
the class QueryStringTest 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;
}
});
}
Aggregations