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) {
     if (jerseyRootPath.isPresent()) {
       jersey.setUrlPattern(jerseyRootPath.get());
     }
     jersey.register(new JacksonMessageBodyProvider(objectMapper));
     jersey.register(new HibernateValidationFeature(validator));
     if (registerDefaultExceptionMappers == null || registerDefaultExceptionMappers) {
       jersey.register(new LoggingExceptionMapper<Throwable>() {});
       jersey.register(new JerseyViolationExceptionMapper());
       jersey.register(new JsonProcessingExceptionMapper());
       jersey.register(new EarlyEofExceptionMapper());
     }
     handler.addServlet(new NonblockingServletHolder(jerseyContainer), jersey.getUrlPattern());
   }
   final InstrumentedHandler instrumented = new InstrumentedHandler(metricRegistry);
   instrumented.setServer(server);
   instrumented.setHandler(handler);
   return instrumented;
 }
 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;
 }