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());
  }
Example #3
0
 /**
  * Sets the given Jersey property.
  *
  * @param name the name of the Jersey property
  * @param value the value of the Jersey property
  * @see ResourceConfig
  */
 public void setJerseyProperty(String name, @Nullable Object value) {
   config.getProperties().put(checkNotNull(name), value);
 }
Example #4
0
 /**
  * Disables the Jersey feature with the given name.
  *
  * @param name the name of the feature to be disabled
  * @see ResourceConfig
  */
 public void disableJerseyFeature(String name) {
   config.getFeatures().put(checkNotNull(name), Boolean.FALSE);
 }
Example #5
0
 /**
  * Adds the given class as a Jersey provider.
  *
  * <p><b>N.B.:</b> This class must either have a no-args constructor or use Jersey's built-in
  * dependency injection.
  *
  * @param klass a Jersey provider class
  */
 public void addProvider(Class<?> klass) {
   config.getClasses().add(checkNotNull(klass));
 }
Example #6
0
 /**
  * Adds the given object as a Jersey provider.
  *
  * @param provider a Jersey provider
  */
 public void addProvider(Object provider) {
   config.getSingletons().add(checkNotNull(provider));
 }
Example #7
0
 /**
  * Adds the given class as a Jersey resource.
  *
  * <p><b>N.B.:</b> This class must either have a no-args constructor or use Jersey's built-in
  * dependency injection.
  *
  * @param klass a Jersey resource class
  */
 public void addResource(Class<?> klass) {
   config.getClasses().add(checkNotNull(klass));
 }
Example #8
0
 /**
  * Adds the given object as a Jersey singleton resource.
  *
  * @param resource a Jersey singleton resource
  */
 public void addResource(Object resource) {
   config.getSingletons().add(checkNotNull(resource));
 }