3

Does anyone knows how to create a custom annotation, what measures for example the amount of incoming String array parameters? Something like this:

@POST
@Timed
@ExceptionMetered
@MeasureArray
public Response postJob(String[] array)
{
    //...
}

And some sort of this code should be used to measure:

Counter counter = metrics.counter("nameOfCounter");
        counter.inc();

How can I implement this?Any idea?

This does not help:

  1. Custom Method Annotation using Jersey's AbstractHttpContextInjectable not Working
  2. https://gist.github.com/ryankennedy/6688601 -> How to add ito DW service is missing.

For 2.): Add in your run():

environment.jersey().register(AuditedMethodDispatchAdapter.class);

with this class:

import javax.ws.rs.ext.Provider;
import org.slf4j.LoggerFactory;
import com.sun.jersey.spi.container.ResourceMethodDispatchAdapter;
import com.sun.jersey.spi.container.ResourceMethodDispatchProvider;

@Provider
public class AuditedMethodDispatchAdapter implements ResourceMethodDispatchAdapter
{

    @Override
    public ResourceMethodDispatchProvider adapt(ResourceMethodDispatchProvider provider) {
        return new AuditedMethodDispatchProvider(provider,LoggerFactory.getLogger(AuditedMethodDispatchAdapter.class),true);
    }

}

and it works for this special context.

Community
  • 1
  • 1
user3280180
  • 1,393
  • 1
  • 11
  • 27

0 Answers0