A guice servlet module that registers the
AdminServlet
via guice and also configures all
healthchecks bound via guice to it.
To use, install this module in your servlet module (or add as a separate module), and bind the health checks
via a multi binder:
install(new AdminServletModule());
Multibinder<HealthCheck> healthChecksBinder = Multibinder.newSetBinder(binder(), HealthCheck.class);
healthChecksBinder.addBinding().to(MyCoolHealthCheck.class);
healthChecksBinder.addBinding().to(MyOtherCoolHealthCheck.class);
The module offers the same overloaded constructors to specifiy a custom
JsonFactory
and the uris
for the healthcheck, metrics, etc. E.g.
install(new AdminServletModule("/1.0/healthcheck", "/1.0/metrics", "/1.0/ping", "/1.0/threads"));
In order to use this module, you need the
guice-servlet
and
guice-multibindings
dependencies in addition to the normal
guice
dependency:
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
<version>3.0</version>
</dependency>