use of io.dropwizard.jetty.NonblockingServletHolder in project dropwizard by dropwizard.
the class AbstractServerFactory method createAdminServlet.
protected Handler createAdminServlet(Server server, MutableServletContextHandler handler, MetricRegistry metrics, HealthCheckRegistry healthChecks) {
configureSessionsAndSecurity(handler, server);
handler.setServer(server);
handler.getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metrics);
handler.getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthChecks);
handler.addServlet(new NonblockingServletHolder(new AdminServlet()), "/*");
handler.addFilter(AllowedMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)).setInitParameter(AllowedMethodsFilter.ALLOWED_METHODS_PARAM, Joiner.on(',').join(allowedMethods));
return handler;
}
use of io.dropwizard.jetty.NonblockingServletHolder in project dropwizard by dropwizard.
the class AbstractServerFactory method createAppServlet.
protected Handler createAppServlet(Server server, JerseyEnvironment jersey, ObjectMapper objectMapper, Validator validator, MutableServletContextHandler handler, @Nullable Servlet jerseyContainer, MetricRegistry metricRegistry) {
configureSessionsAndSecurity(handler, server);
handler.addFilter(AllowedMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)).setInitParameter(AllowedMethodsFilter.ALLOWED_METHODS_PARAM, Joiner.on(',').join(allowedMethods));
handler.addFilter(ThreadNameFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
serverPush.addFilter(handler);
if (jerseyContainer != null) {
jerseyRootPath.ifPresent(jersey::setUrlPattern);
jersey.register(new JacksonBinder(objectMapper));
jersey.register(new HibernateValidationFeature(validator));
if (registerDefaultExceptionMappers == null || registerDefaultExceptionMappers) {
jersey.register(new ExceptionMapperBinder(detailedJsonProcessingExceptionMapper));
}
handler.addServlet(new NonblockingServletHolder(jerseyContainer), jersey.getUrlPattern());
}
final InstrumentedHandler instrumented = new InstrumentedHandler(metricRegistry);
instrumented.setServer(server);
instrumented.setHandler(handler);
return instrumented;
}
use of io.dropwizard.jetty.NonblockingServletHolder in project dropwizard by dropwizard.
the class ServletEnvironment method addServlet.
/**
* Add a servlet instance.
*
* @param name the servlet's name
* @param servlet the servlet instance
* @return a {@link javax.servlet.ServletRegistration.Dynamic} instance allowing for further
* configuration
*/
public ServletRegistration.Dynamic addServlet(String name, Servlet servlet) {
final ServletHolder holder = new NonblockingServletHolder(requireNonNull(servlet));
holder.setName(name);
handler.getServletHandler().addServlet(holder);
final ServletRegistration.Dynamic registration = holder.getRegistration();
checkDuplicateRegistration(name, servlets, "servlet");
return registration;
}
Aggregations