我有ebean实体:
enter code here
@Entity
public class Company extends Model {
@Id
public Long id;
static void foo {
Logger.info("in company");
}
...
}
定义拦截器的guice模块:
public class Module extends AbstractModule {
protected void configure() {
CacheImpl cache = new CacheImpl();
requestInjection(cache);
bindInterceptor(subclassesOf(Company.class), any(), cache);
}
}
这不会拦截对公司的任何调用(foo(),save(),get(),find()..)
当我将bindInterceptor更改为扩展Play Controller的类时,它通过拦截调用来工作。
有人可以告诉我,如果我遗失了什么吗?
my methodInterceptor:
@Component
public class CacheImpl implements MethodInterceptor {
public Object invoke(MethodInvocation method) throws Throwable{
Logger.info("class {}",method.getClass().getName());
if (method.getMethod().getName() == "list") {
Logger.info("interceptor in list");
} else {
Logger.info("in interceptor for {}", method.getMethod().getName());
}
return method.proceed();
}
}