Search in sources :

Example 96 with HandlerCollection

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

the class AegisServer 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("/");
    webappcontext.setBaseResource(Resource.newClassPathResource("/webapp"));
    server.setHandler(new HandlerCollection(webappcontext, new DefaultHandler()));
    try {
        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 97 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.setBaseResource(Resource.newClassPathResource(resourcePath));
            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 98 with HandlerCollection

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

the class AthenzJettyContainer method createServer.

public void createServer(int maxThreads) {
    // Setup Thread pool
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMaxThreads(maxThreads);
    server = new Server(threadPool);
    handlers = new HandlerCollection();
    server.setHandler(handlers);
}
Also used : Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection)

Example 99 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());
    ContextHandlerCollection handlers = new ContextHandlerCollection();
    deploymentManager.setContexts(handlers);
    createWebAppContext();
    JettyCustomErrorPageHandler errorHandler = new JettyCustomErrorPageHandler();
    webAppContext.setErrorHandler(errorHandler);
    webAppContext.setGzipHandler(gzipHandler());
    server.addBean(errorHandler);
    server.addBean(deploymentManager);
    HandlerCollection serverLevelHandlers = new HandlerCollection();
    serverLevelHandlers.setHandlers(new Handler[] { handlers });
    server.setHandler(serverLevelHandlers);
    performCustomConfiguration();
    server.setStopAtShutdown(true);
}
Also used : ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection)

Example 100 with HandlerCollection

use of org.eclipse.jetty.server.handler.HandlerCollection in project incubator-pulsar by apache.

the class WorkerServer method run.

@Override
public void run() {
    final Server server = new Server(this.workerConfig.getWorkerPort());
    List<Handler> handlers = new ArrayList<>(2);
    handlers.add(newServletContextHandler("/admin", new ResourceConfig(Resources.getApiResources()), workerService));
    handlers.add(newServletContextHandler("/admin/v2", new ResourceConfig(Resources.getApiResources()), workerService));
    handlers.add(newServletContextHandler("/", new ResourceConfig(Resources.getRootResources()), workerService));
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
    HandlerCollection handlerCollection = new HandlerCollection();
    handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler() });
    server.setHandler(handlerCollection);
    try {
        server.start();
        log.info("Worker Server started at {}", server.getURI());
        server.join();
    } catch (Exception ex) {
        log.error("ex: {}", ex, ex);
        final String message = getErrorMessage(server, this.workerConfig.getWorkerPort(), ex);
        log.error(message);
        System.exit(1);
    } finally {
        server.destroy();
    }
}
Also used : Server(org.eclipse.jetty.server.Server) ArrayList(java.util.ArrayList) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) Handler(org.eclipse.jetty.server.Handler) DefaultHandler(org.eclipse.jetty.server.handler.DefaultHandler) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) BindException(java.net.BindException) 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