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()); }
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()); }
/** * Adds the given object as a Jersey provider. * * @param provider a Jersey provider */ public void addProvider(Object provider) { config.getSingletons().add(checkNotNull(provider)); }
/** * 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)); }