コード例 #1
0
ファイル: Environment.java プロジェクト: koutsoub/dropwizard
  /**
   * 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());
  }
コード例 #2
0
ファイル: Environment.java プロジェクト: koutsoub/dropwizard
 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());
 }
コード例 #3
0
ファイル: Environment.java プロジェクト: koutsoub/dropwizard
 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());
 }
コード例 #4
0
ファイル: Environment.java プロジェクト: koutsoub/dropwizard
  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());
  }