有谁知道如何创建自定义注释,例如传入的String数组参数量是多少?像这样:
@POST
@Timed
@ExceptionMetered
@MeasureArray
public Response postJob(String[] array)
{
//...
}
应该使用某种代码来衡量:
Counter counter = metrics.counter("nameOfCounter");
counter.inc();
我该如何实现?任何想法?
这没有用:
对于2.): 添加你的run():
environment.jersey().register(AuditedMethodDispatchAdapter.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);
}
}
它适用于这种特殊背景。