use of org.eclipse.jetty.server.handler.HandlerWrapper in project spring-boot by spring-projects.
the class JettyServletWebServerFactoryTests method wrappedHandlers.
@Test
public void wrappedHandlers() throws Exception {
JettyServletWebServerFactory factory = getFactory();
factory.setServerCustomizers(Arrays.asList(new JettyServerCustomizer() {
@Override
public void customize(Server server) {
Handler handler = server.getHandler();
HandlerWrapper wrapper = new HandlerWrapper();
wrapper.setHandler(handler);
HandlerCollection collection = new HandlerCollection();
collection.addHandler(wrapper);
server.setHandler(collection);
}
}));
this.webServer = factory.getWebServer(exampleServletRegistration());
this.webServer.start();
assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
}
use of org.eclipse.jetty.server.handler.HandlerWrapper in project processdash by dtuma.
the class WebServer method createServer.
private void createServer() {
// compile JSPs using an internal compiler, not a JDK javac executable
System.setProperty("org.apache.jasper.compiler.disablejsr199", "true");
// create a new Jetty server
server = new Server();
server.setAttribute(DEFAULT_ENV_KEY, Collections.unmodifiableMap(DEFAULT_ENV));
// the server thread pool should use daemon threads
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("WebServer");
threadPool.setDaemon(true);
server.setThreadPool(threadPool);
// create a local connector which can be used for internal requests
localConnector = new LocalConnector();
server.addConnector(localConnector);
// create a handler chain to serve requests
webApps = new ContextHandlerCollection();
webApps.setHandlers(new Handler[0]);
HandlerWrapper interceptor = new DashboardHttpRequestInterceptor(startupTimestamp);
interceptor.setHandler(webApps);
server.setHandler(interceptor);
// start the server
try {
server.start();
} catch (Exception e) {
logger.log(Level.SEVERE, "Could not start web server", e);
}
}
use of org.eclipse.jetty.server.handler.HandlerWrapper in project camel by apache.
the class WebsocketComponent method createContext.
protected ServletContextHandler createContext(Server server, Connector connector, List<Handler> handlers) throws Exception {
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
server.addConnector(connector);
if (handlers != null && !handlers.isEmpty()) {
for (Handler handler : handlers) {
if (handler instanceof HandlerWrapper) {
((HandlerWrapper) handler).setHandler(server.getHandler());
server.setHandler(handler);
} else {
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.addHandler(server.getHandler());
handlerCollection.addHandler(handler);
server.setHandler(handlerCollection);
}
}
}
return context;
}
use of org.eclipse.jetty.server.handler.HandlerWrapper in project jetty.project by eclipse.
the class HandlerTest method testWrapperChainLoop.
@Test
public void testWrapperChainLoop() {
HandlerWrapper a = new HandlerWrapper();
HandlerWrapper b = new HandlerWrapper();
HandlerWrapper c = new HandlerWrapper();
a.setHandler(b);
c.setHandler(a);
try {
b.setHandler(c);
fail();
} catch (IllegalStateException e) {
assertThat(e.getMessage(), containsString("loop"));
}
}
use of org.eclipse.jetty.server.handler.HandlerWrapper in project jetty.project by eclipse.
the class HandlerTest method testWrapperThisLoop.
@Test
public void testWrapperThisLoop() {
HandlerWrapper a = new HandlerWrapper();
try {
a.setHandler(a);
fail();
} catch (IllegalStateException e) {
assertThat(e.getMessage(), containsString("loop"));
}
}
Aggregations