Skip to content

Commit

Permalink
Merge pull request dropwizard#492 from pimlottc/resource-logging
Browse files Browse the repository at this point in the history
use Jersey's own logic to filter resource and provider classes for logging
  • Loading branch information
nicktelford committed Mar 12, 2014
2 parents 7fe1a60 + 40dc9e9 commit 52ad9ce
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.sun.jersey.api.core.ResourceConfig;
import com.sun.jersey.api.core.ScanningResourceConfig;
import com.sun.jersey.api.model.AbstractResource;
import com.sun.jersey.api.model.AbstractResourceMethod;
Expand Down Expand Up @@ -76,13 +77,13 @@ private void logResources() {
final ImmutableSet.Builder<String> builder = ImmutableSet.builder();

for (Class<?> klass : getClasses()) {
if (klass.isAnnotationPresent(Path.class)) {
if (ResourceConfig.isRootResourceClass(klass)) {
builder.add(klass.getCanonicalName());
}
}

for (Object o : getSingletons()) {
if (o.getClass().isAnnotationPresent(Path.class)) {
if (ResourceConfig.isRootResourceClass(o.getClass())) {
builder.add(o.getClass().getCanonicalName());
}
}
Expand All @@ -102,13 +103,13 @@ private void logProviders() {
final ImmutableSet.Builder<String> builder = ImmutableSet.builder();

for (Class<?> klass : getClasses()) {
if (klass.isAnnotationPresent(Provider.class)) {
if (ResourceConfig.isProviderClass(klass)) {
builder.add(klass.getCanonicalName());
}
}

for (Object o : getSingletons()) {
if (o.getClass().isAnnotationPresent(Provider.class)) {
if (ResourceConfig.isProviderClass(o.getClass())) {
builder.add(o.getClass().getCanonicalName());
}
}
Expand All @@ -123,12 +124,12 @@ private void logEndpoints() {

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

0 comments on commit 52ad9ce

Please sign in to comment.