Does anyone know how to get the same information, about what paths are used, like at the start of dw application. I mean the output after this line:
io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
GET /path/of/res/test (this.is.the.class.package.info.MyRessource)
POST /path/of/res/test2 (this.is.the.class.package.info.MyRessource2)
I have to check if specific path exists.
Because you can't be a web application without HTTP, Dropwizard uses the Jetty HTTP library to embed an incredibly tuned HTTP server directly into your project.
Dropwizard uses Logback for its logging backend. It provides an slf4j implementation, and even routes all java. util. logging , Log4j, and Apache Commons Logging usage through Logback.
Bootstrap is the pre-start (temp) application environment, containing everything required to bootstrap a Dropwizard command. Here is a simplified code snippet to illustrate its structure: Bootstrap(application: Application<T>) { this. application = application; this. objectMapper = Jackson.
You'll have to do this on your own. Take a look at the logEndpoints
method (which is what actually logs this information - with private methods). You should be able to adapt this method to handle the resources from your environment.jersey().getResourceConfig()
after you configure your resources in your run
method.
Something like:
final ImmutableList.Builder<Class<?>> builder = ImmutableList.builder();
for (Object o : environment.jersey().getResourceConfig().getSingletons()) {
if (o.getClass().isAnnotationPresent(Path.class)) {
builder.add(o.getClass());
}
}
for (Class<?> klass : environment.jersey().getResourceConfig().getClasses()) {
if (klass.isAnnotationPresent(Path.class)) {
builder.add(klass);
}
}
final List<String> endpoints = Lists.newArrayList();
for (Class<?> klass : builder.build()) {
AbstractResource resource = IntrospectionModeller.createResource(klass);
endpoints.add(resource.getPath().getValue());
}
Note that what's in master is slightly ahead of what's in Maven - the above example shows how to get the AbstractResource
which will work with 0.7.1. You'll have to be sure to adapt your method as dropwizard evolves. This example also doesn't normalize the path but I you can easily add that based on logEndpoints
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With