Guice 拦截器被调用两次
Guice interceptor invoked twice
如果我有一个注释
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD})
public @interface RESTMonitor {
}
如果我在同一 class 中同时在 class 级别和方法级别上使用它。那我如何限制它只执行一次。现在它被调用了两次。
因此您有两个 bindInterceptor()
调用,这通常会导致调用两个不同的拦截器。但是,如果您将相同的拦截器传递给两个调用,它们将被删除重复数据:
RESTMonitorMethodInterceptor interceptor = new RESTMonitorMethodInterceptor();
bindInterceptor(Matchers.annotatedWith(RESTMonitor.class), Matchers.any(), interceptor);
bindInterceptor(Matchers.any(), Matchers.annotatedWith(RESTMonitor.class), interceptor);
(我implemented这个功能。)
如果我有一个注释
@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD})
public @interface RESTMonitor {
}
如果我在同一 class 中同时在 class 级别和方法级别上使用它。那我如何限制它只执行一次。现在它被调用了两次。
因此您有两个 bindInterceptor()
调用,这通常会导致调用两个不同的拦截器。但是,如果您将相同的拦截器传递给两个调用,它们将被删除重复数据:
RESTMonitorMethodInterceptor interceptor = new RESTMonitorMethodInterceptor();
bindInterceptor(Matchers.annotatedWith(RESTMonitor.class), Matchers.any(), interceptor);
bindInterceptor(Matchers.any(), Matchers.annotatedWith(RESTMonitor.class), interceptor);
(我implemented这个功能。)