/** * Creates a new environment. * * @param configuration the service's {@link Configuration} * @param service the service */ public Environment(Configuration configuration, AbstractService<?> service) { this.service = service; this.config = new DropwizardResourceConfig() { @Override public void validate() { super.validate(); logResources(); logProviders(); logHealthChecks(); logManagedObjects(); logEndpoints(); } }; this.healthChecks = ImmutableSet.builder(); this.servlets = ImmutableMap.builder(); this.filters = ImmutableMultimap.builder(); this.servletListeners = ImmutableSet.builder(); this.tasks = ImmutableSet.builder(); this.lifeCycle = new AggregateLifeCycle(); final HttpServlet jerseyContainer = service.getJerseyContainer(config); if (jerseyContainer != null) { addServlet(jerseyContainer, configuration.getHttpConfiguration().getRootPath()) .setInitOrder(Integer.MAX_VALUE); } addTask(new GarbageCollectionTask()); }
private void logHealthChecks() { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (HealthCheck healthCheck : healthChecks.build()) { builder.add(healthCheck.getClass().getCanonicalName()); } LOG.debug("health checks = {}", builder.build()); }
private void logManagedObjects() { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (Object bean : lifeCycle.getBeans()) { builder.add(bean.getClass().getCanonicalName()); } LOG.debug("managed objects = {}", builder.build()); }
private void logProviders() { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); for (Class<?> klass : config.getClasses()) { if (klass.isAnnotationPresent(Provider.class)) { builder.add(klass.getCanonicalName()); } } for (Object o : config.getSingletons()) { if (o.getClass().isAnnotationPresent(Provider.class)) { builder.add(o.getClass().getCanonicalName()); } } LOG.debug("providers = {}", builder.build()); }