Search in sources :

Example 1 with RoutingHandler

use of io.dropwizard.jetty.RoutingHandler in project dropwizard by dropwizard.

the class DefaultServerFactory method build.

@Override
public Server build(Environment environment) {
    // ensures that the environment is configured before the server is built
    configure(environment);
    printBanner(environment.getName());
    final ThreadPool threadPool = createThreadPool(environment.metrics());
    final Server server = buildServer(environment.lifecycle(), threadPool);
    final Handler applicationHandler = createAppServlet(server, environment.jersey(), environment.getObjectMapper(), environment.getValidator(), environment.getApplicationContext(), environment.getJerseyServletContainer(), environment.metrics());
    final Handler adminHandler = createAdminServlet(server, environment.getAdminContext(), environment.metrics(), environment.healthChecks());
    final RoutingHandler routingHandler = buildRoutingHandler(environment.metrics(), server, applicationHandler, adminHandler);
    final Handler gzipHandler = buildGzipHandler(routingHandler);
    server.setHandler(addStatsHandler(addRequestLog(server, gzipHandler, environment.getName())));
    return server;
}
Also used : Server(org.eclipse.jetty.server.Server) RoutingHandler(io.dropwizard.jetty.RoutingHandler) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ThreadPool(org.eclipse.jetty.util.thread.ThreadPool) RoutingHandler(io.dropwizard.jetty.RoutingHandler) Handler(org.eclipse.jetty.server.Handler)

Example 2 with RoutingHandler

use of io.dropwizard.jetty.RoutingHandler in project dropwizard by dropwizard.

the class DefaultServerFactory method buildRoutingHandler.

private RoutingHandler buildRoutingHandler(MetricRegistry metricRegistry, Server server, Handler applicationHandler, Handler adminHandler) {
    final List<Connector> appConnectors = buildAppConnectors(metricRegistry, server);
    final List<Connector> adConnectors = buildAdminConnectors(metricRegistry, server);
    final Map<Connector, Handler> handlers = new LinkedHashMap<>();
    for (Connector connector : appConnectors) {
        server.addConnector(connector);
        handlers.put(connector, applicationHandler);
    }
    for (Connector connector : adConnectors) {
        server.addConnector(connector);
        handlers.put(connector, adminHandler);
    }
    return new RoutingHandler(handlers);
}
Also used : Connector(org.eclipse.jetty.server.Connector) RoutingHandler(io.dropwizard.jetty.RoutingHandler) RoutingHandler(io.dropwizard.jetty.RoutingHandler) Handler(org.eclipse.jetty.server.Handler) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

RoutingHandler (io.dropwizard.jetty.RoutingHandler)2 Handler (org.eclipse.jetty.server.Handler)2 LinkedHashMap (java.util.LinkedHashMap)1 Connector (org.eclipse.jetty.server.Connector)1 Server (org.eclipse.jetty.server.Server)1 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)1 ThreadPool (org.eclipse.jetty.util.thread.ThreadPool)1