Package com.codahale.metrics.servlets
Class MetricsServlet.ContextListener
- java.lang.Object
-
- com.codahale.metrics.servlets.MetricsServlet.ContextListener
-
- All Implemented Interfaces:
EventListener
,javax.servlet.ServletContextListener
- Enclosing class:
- MetricsServlet
public abstract static class MetricsServlet.ContextListener extends Object implements javax.servlet.ServletContextListener
An abstractServletContextListener
which allows you to programmatically inject theMetricRegistry
, rate and duration units, and allowed origin forMetricsServlet
.
-
-
Constructor Summary
Constructors Constructor Description ContextListener()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
contextDestroyed(javax.servlet.ServletContextEvent event)
void
contextInitialized(javax.servlet.ServletContextEvent event)
protected String
getAllowedOrigin()
protected TimeUnit
getDurationUnit()
protected String
getJsonpCallbackParameter()
Returns the name of the parameter used to specify the jsonp callback, if any.protected MetricFilter
getMetricFilter()
Returns theMetricFilter
that shall be used to filter metrics, orMetricFilter.ALL
if the default should be used.protected abstract MetricRegistry
getMetricRegistry()
protected TimeUnit
getRateUnit()
-
-
-
Method Detail
-
getMetricRegistry
protected abstract MetricRegistry getMetricRegistry()
- Returns:
- the
MetricRegistry
to inject into the servlet context.
-
getRateUnit
protected TimeUnit getRateUnit()
- Returns:
- the
TimeUnit
to which rates should be converted, ornull
if the default should be used.
-
getDurationUnit
protected TimeUnit getDurationUnit()
- Returns:
- the
TimeUnit
to which durations should be converted, ornull
if the default should be used.
-
getAllowedOrigin
protected String getAllowedOrigin()
- Returns:
- the
Access-Control-Allow-Origin
header value, if any.
-
getJsonpCallbackParameter
protected String getJsonpCallbackParameter()
Returns the name of the parameter used to specify the jsonp callback, if any.
-
getMetricFilter
protected MetricFilter getMetricFilter()
Returns theMetricFilter
that shall be used to filter metrics, orMetricFilter.ALL
if the default should be used.
-
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent event)
- Specified by:
contextInitialized
in interfacejavax.servlet.ServletContextListener
-
contextDestroyed
public void contextDestroyed(javax.servlet.ServletContextEvent event)
- Specified by:
contextDestroyed
in interfacejavax.servlet.ServletContextListener
-
-