Search in sources :

Example 1 with HealthCheckFilter

use of com.codahale.metrics.health.HealthCheckFilter in project metrics by dropwizard.

the class HealthCheckServlet method init.

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);
    final ServletContext context = config.getServletContext();
    if (null == registry) {
        final Object registryAttr = context.getAttribute(HEALTH_CHECK_REGISTRY);
        if (registryAttr instanceof HealthCheckRegistry) {
            this.registry = (HealthCheckRegistry) registryAttr;
        } else {
            throw new ServletException("Couldn't find a HealthCheckRegistry instance.");
        }
    }
    final Object executorAttr = context.getAttribute(HEALTH_CHECK_EXECUTOR);
    if (executorAttr instanceof ExecutorService) {
        this.executorService = (ExecutorService) executorAttr;
    }
    final Object filterAttr = context.getAttribute(HEALTH_CHECK_FILTER);
    if (filterAttr instanceof HealthCheckFilter) {
        filter = (HealthCheckFilter) filterAttr;
    }
    if (filter == null) {
        filter = HealthCheckFilter.ALL;
    }
    this.mapper = new ObjectMapper().registerModule(new HealthCheckModule());
}
Also used : ServletException(javax.servlet.ServletException) HealthCheckRegistry(com.codahale.metrics.health.HealthCheckRegistry) ExecutorService(java.util.concurrent.ExecutorService) ServletContext(javax.servlet.ServletContext) HealthCheckModule(com.codahale.metrics.json.HealthCheckModule) HealthCheckFilter(com.codahale.metrics.health.HealthCheckFilter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

HealthCheckFilter (com.codahale.metrics.health.HealthCheckFilter)1 HealthCheckRegistry (com.codahale.metrics.health.HealthCheckRegistry)1 HealthCheckModule (com.codahale.metrics.json.HealthCheckModule)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ExecutorService (java.util.concurrent.ExecutorService)1 ServletContext (javax.servlet.ServletContext)1 ServletException (javax.servlet.ServletException)1