use of org.eclipse.jetty.servlet.ServletContextHandler in project jetty.project by eclipse.
the class WebSocketCdiInitializer method onStartup.
@Override
public void onStartup(Set<Class<?>> c, ServletContext context) throws ServletException {
ContextHandler handler = ContextHandler.getContextHandler(context);
if (handler == null) {
throw new ServletException("Not running on Jetty, WebSocket+CDI support unavailable");
}
if (!(handler instanceof ServletContextHandler)) {
throw new ServletException("Not running in Jetty ServletContextHandler, WebSocket+CDI support unavailable");
}
ServletContextHandler jettyContext = (ServletContextHandler) handler;
try (ThreadClassLoaderScope scope = new ThreadClassLoaderScope(context.getClassLoader())) {
addListeners(jettyContext);
}
}
use of org.eclipse.jetty.servlet.ServletContextHandler in project jetty.project by eclipse.
the class BalancerServletTest method createServer.
private Server createServer(ServletHolder servletHolder, String nodeName) {
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
server.addConnector(connector);
ServletContextHandler context = new ServletContextHandler(server, CONTEXT_PATH, ServletContextHandler.SESSIONS);
context.addServlet(servletHolder, SERVLET_PATH + "/*");
if (nodeName != null) {
DefaultSessionIdManager sessionIdManager = new DefaultSessionIdManager(server);
sessionIdManager.setWorkerName(nodeName);
server.setSessionIdManager(sessionIdManager);
}
return server;
}
use of org.eclipse.jetty.servlet.ServletContextHandler in project jetty.project by eclipse.
the class ProxyServletTest method startServer.
private void startServer(HttpServlet servlet) throws Exception {
QueuedThreadPool serverPool = new QueuedThreadPool();
serverPool.setName("server");
server = new Server(serverPool);
serverConnector = new ServerConnector(server);
server.addConnector(serverConnector);
ServletContextHandler appCtx = new ServletContextHandler(server, "/", true, false);
ServletHolder appServletHolder = new ServletHolder(servlet);
appCtx.addServlet(appServletHolder, "/*");
server.start();
}
use of org.eclipse.jetty.servlet.ServletContextHandler in project jetty.project by eclipse.
the class ReverseProxyTest method startServer.
private void startServer(HttpServlet servlet) throws Exception {
server = new Server();
serverConnector = new ServerConnector(server);
server.addConnector(serverConnector);
ServletContextHandler appCtx = new ServletContextHandler(server, "/", true, false);
ServletHolder appServletHolder = new ServletHolder(servlet);
appCtx.addServlet(appServletHolder, "/*");
server.start();
}
use of org.eclipse.jetty.servlet.ServletContextHandler in project jetty.project by eclipse.
the class ProxyServletTest method startProxy.
private void startProxy(Map<String, String> initParams) throws Exception {
QueuedThreadPool proxyPool = new QueuedThreadPool();
proxyPool.setName("proxy");
proxy = new Server(proxyPool);
HttpConfiguration configuration = new HttpConfiguration();
configuration.setSendDateHeader(false);
configuration.setSendServerVersion(false);
String value = initParams.get("outputBufferSize");
if (value != null)
configuration.setOutputBufferSize(Integer.valueOf(value));
proxyConnector = new ServerConnector(proxy, new HttpConnectionFactory(configuration));
proxy.addConnector(proxyConnector);
proxyContext = new ServletContextHandler(proxy, "/", true, false);
ServletHolder proxyServletHolder = new ServletHolder(proxyServlet);
proxyServletHolder.setInitParameters(initParams);
proxyContext.addServlet(proxyServletHolder, "/*");
proxy.start();
}
Aggregations