Search in sources :

Example 61 with HandlerCollection

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

the class Jetty9Server method configure.

@Override
public void configure() throws Exception {
    server.addEventListener(mbeans());
    server.addConnector(plainConnector());
    server.addConnector(sslConnector());
    HandlerCollection handlers = new HandlerCollection();
    handlers.addHandler(welcomeFileHandler());
    createWebAppContext();
    addResourceHandler(handlers, webAppContext);
    handlers.addHandler(gzipHandler(webAppContext));
    JettyCustomErrorPageHandler errorHandler = new JettyCustomErrorPageHandler();
    webAppContext.setErrorHandler(errorHandler);
    server.addBean(errorHandler);
    server.setHandler(handlers);
    performCustomConfiguration();
    server.setStopAtShutdown(true);
}
Also used : HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection)

Example 62 with HandlerCollection

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

the class DigestServer method run.

protected void run() {
    // System.out.println("Starting Server");
    server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
    WebAppContext webappcontext = new WebAppContext();
    webappcontext.setContextPath("/digestauth");
    String warPath = null;
    try {
        URL res = getClass().getResource("/digestauth");
        warPath = res.toURI().getPath();
    } catch (URISyntaxException e1) {
        e1.printStackTrace();
    }
    webappcontext.setWar(warPath);
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
    server.setHandler(handlers);
    try {
        configureServer();
        server.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) URISyntaxException(java.net.URISyntaxException) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler)

Example 63 with HandlerCollection

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

the class AbstractJettyServer method run.

protected void run() {
    System.setProperty("java.naming.factory.url", "org.eclipse.jetty.jndi");
    System.setProperty("java.naming.factory.initial", "org.eclipse.jetty.jndi.InitialContextFactory");
    server = new Server(port);
    try {
        if (resourcePath == null) {
            // Register and map the dispatcher servlet
            final ServletHolder servletHolder = new ServletHolder(new CXFCdiServlet());
            final ServletContextHandler context = new ServletContextHandler();
            context.setContextPath(contextPath);
            context.addEventListener(listener);
            context.addServlet(servletHolder, "/rest/*");
            server.setHandler(context);
        } else {
            final WebAppContext context = new WebAppContext();
            context.setContextPath(contextPath);
            context.setWar(getClass().getResource(resourcePath).toURI().getPath());
            context.setServerClasses(new String[] { "org.eclipse.jetty.servlet.ServletContextHandler.Decorator" });
            HandlerCollection handlers = new HandlerCollection();
            handlers.setHandlers(new Handler[] { context, new DefaultHandler() });
            server.setHandler(handlers);
        }
        server.start();
    } catch (final Exception ex) {
        ex.printStackTrace();
        fail(ex.getMessage());
    }
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) Server(org.eclipse.jetty.server.Server) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) CXFCdiServlet(org.apache.cxf.cdi.CXFCdiServlet) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler)

Example 64 with HandlerCollection

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

the class OpenApiServer method run.

protected void run() {
    server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
    WebAppContext webappcontext = new WebAppContext();
    String contextPath = null;
    try {
        contextPath = getClass().getResource("/jaxrs_openapi_v3").toURI().getPath();
    } catch (URISyntaxException e1) {
        e1.printStackTrace();
    }
    webappcontext.setContextPath("/");
    webappcontext.setWar(contextPath);
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
    server.setHandler(handlers);
    try {
        server.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) URISyntaxException(java.net.URISyntaxException) URISyntaxException(java.net.URISyntaxException) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler)

Example 65 with HandlerCollection

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

the class BookDataBindingServer method run.

protected void run() {
    server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
    WebAppContext webappcontext = new WebAppContext();
    String contextPath = null;
    try {
        contextPath = getClass().getResource("/jaxrs_databinding").toURI().getPath();
    } catch (URISyntaxException e1) {
        e1.printStackTrace();
    }
    webappcontext.setContextPath("/");
    webappcontext.setWar(contextPath);
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
    server.setHandler(handlers);
    try {
        server.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) URISyntaxException(java.net.URISyntaxException) URISyntaxException(java.net.URISyntaxException) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler)

Aggregations

HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)76 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)44 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)30 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)27 Server (org.eclipse.jetty.server.Server)26 URISyntaxException (java.net.URISyntaxException)18 ServerConnector (org.eclipse.jetty.server.ServerConnector)18 RequestLogHandler (org.eclipse.jetty.server.handler.RequestLogHandler)18 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)16 Handler (org.eclipse.jetty.server.Handler)15 Test (org.junit.Test)13 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)9 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)9 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)8 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)7 GzipHandler (org.eclipse.jetty.servlets.gzip.GzipHandler)6 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)6 File (java.io.File)5 URI (java.net.URI)5 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)5