Search in sources :

Example 91 with HandlerCollection

use of org.eclipse.jetty.server.handler.HandlerCollection in project helios by spotify.

the class MasterService method setUpRequestLogging.

private void setUpRequestLogging(final Path stateDirectory) {
    // Set up request logging
    final Handler originalHandler = server.getHandler();
    final HandlerCollection handlerCollection;
    if (originalHandler instanceof HandlerCollection) {
        handlerCollection = (HandlerCollection) originalHandler;
    } else {
        handlerCollection = new HandlerCollection();
        handlerCollection.addHandler(originalHandler);
    }
    final RequestLogHandler requestLogHandler = new RequestLogHandler();
    final RequestLogImpl requestLog = new RequestLogImpl();
    requestLog.setQuiet(true);
    if (stateDirectory.resolve(LOGBACK_ACCESS_CONFIG).toFile().exists()) {
        requestLog.setFileName(stateDirectory.resolve(LOGBACK_ACCESS_CONFIG).toString());
    } else if (this.getClass().getResource(LOGBACK_ACCESS_RESOURCE) != null) {
        requestLog.setResource(LOGBACK_ACCESS_RESOURCE);
    }
    requestLogHandler.setRequestLog(requestLog);
    handlerCollection.addHandler(requestLogHandler);
    server.setHandler(handlerCollection);
}
Also used : RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) RequestLogImpl(ch.qos.logback.access.jetty.RequestLogImpl) Handler(org.eclipse.jetty.server.Handler) RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection)

Example 92 with HandlerCollection

use of org.eclipse.jetty.server.handler.HandlerCollection in project cxf by apache.

the class AbstractSpringServer method run.

protected void run() {
    server = new org.eclipse.jetty.server.Server(port);
    WebAppContext webappcontext = new WebAppContext();
    webappcontext.setContextPath(contextPath);
    webappcontext.setBaseResource(Resource.newClassPathResource(resourcePath));
    server.setHandler(new HandlerCollection(webappcontext, new DefaultHandler()));
    try {
        configureServer(server);
        server.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler)

Example 93 with HandlerCollection

use of org.eclipse.jetty.server.handler.HandlerCollection in project cxf by apache.

the class DigestServer method run.

protected void run() {
    server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
    WebAppContext webappcontext = new WebAppContext();
    webappcontext.setContextPath("/digestauth");
    webappcontext.setBaseResource(Resource.newClassPathResource("/digestauth"));
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
    server.setHandler(handlers);
    try {
        configureServer();
        server.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler)

Example 94 with HandlerCollection

use of org.eclipse.jetty.server.handler.HandlerCollection in project cxf by apache.

the class ResolverTest method startServer.

@Test
public void startServer() throws Throwable {
    Server server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
    WebAppContext webappcontext = new WebAppContext();
    webappcontext.setContextPath("/resolver");
    webappcontext.setBaseResource(Resource.newClassPathResource("/resolver"));
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
    server.setHandler(handlers);
    server.start();
    Throwable e = webappcontext.getUnavailableException();
    if (e != null) {
        throw e;
    }
    server.stop();
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Server(org.eclipse.jetty.server.Server) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler) Test(org.junit.Test)

Example 95 with HandlerCollection

use of org.eclipse.jetty.server.handler.HandlerCollection in project cxf by apache.

the class AbstractSpringServer method run.

protected void run() {
    server = new org.eclipse.jetty.server.Server(port);
    WebAppContext webappcontext = new WebAppContext();
    webappcontext.setContextPath(contextPath);
    webappcontext.setBaseResource(Resource.newClassPathResource(resourcePath));
    server.setHandler(new HandlerCollection(webappcontext, new DefaultHandler()));
    try {
        configureServer(server);
        server.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler)

Aggregations

HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)115 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)57 Server (org.eclipse.jetty.server.Server)50 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)40 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)39 ServerConnector (org.eclipse.jetty.server.ServerConnector)34 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)31 RequestLogHandler (org.eclipse.jetty.server.handler.RequestLogHandler)30 Handler (org.eclipse.jetty.server.Handler)26 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)18 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)17 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)17 URISyntaxException (java.net.URISyntaxException)16 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)16 URI (java.net.URI)14 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)13 File (java.io.File)12 IOException (java.io.IOException)11 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)11 Slf4jRequestLog (org.eclipse.jetty.server.Slf4jRequestLog)10