Code example for Method

Methods: getName, isAnnotationPresent

0
 
    @Override 
    public void configure(ResourceInfo resourceInfo, FeatureContext context) {
 
        final Method resourceMethod = resourceInfo.getResourceMethod();
        if (resourceMethod.isAnnotationPresent(Timed.class)) {
            log.debug("Setting up filter for Timed resource method: {}#{}", resourceInfo.getResourceClass().getCanonicalName(), resourceMethod.getName());
            context.register(new TimedMetricsFilter(metricRegistry, resourceInfo));
        } 
        if (resourceMethod.isAnnotationPresent(Metered.class)) {
            log.debug("Setting up filter for Metered resource method: {}#{}", resourceInfo.getResourceClass().getCanonicalName(), resourceMethod.getName());
            context.register(new MeteredMetricsFilter(metricRegistry, resourceInfo));
        } 
        if (resourceMethod.isAnnotationPresent(ExceptionMetered.class)) {
            log.debug("Setting up filter for ExceptionMetered resource method: {}#{}", resourceInfo.getResourceClass().getCanonicalName(), resourceMethod.getName());
            context.register(new ExceptionMeteredMetricsFilter(metricRegistry, resourceInfo));
        } 
    } 
}