Example #1
0
  private void logEndpoints() {
    final StringBuilder stringBuilder = new StringBuilder(1024).append("\n\n");

    final ImmutableList.Builder<Class<?>> builder = ImmutableList.builder();
    for (Object o : config.getSingletons()) {
      if (o.getClass().isAnnotationPresent(Path.class)) {
        builder.add(o.getClass());
      }
    }
    for (Class<?> klass : config.getClasses()) {
      if (klass.isAnnotationPresent(Path.class)) {
        builder.add(klass);
      }
    }

    for (Class<?> klass : builder.build()) {
      final String path = klass.getAnnotation(Path.class).value();
      final ImmutableList.Builder<String> endpoints = ImmutableList.builder();
      for (AnnotatedMethod method : annotatedMethods(klass)) {
        for (HttpMethod verb : method.getMetaMethodAnnotations(HttpMethod.class)) {
          endpoints.add(
              String.format("    %-7s %s (%s)", verb.value(), path, klass.getCanonicalName()));
        }
      }

      for (String line : Ordering.natural().sortedCopy(endpoints.build())) {
        stringBuilder.append(line).append('\n');
      }
    }

    LOG.info(stringBuilder.toString());
  }
Example #2
0
  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());
  }