跳到主要内容

全局拦截器

全局拦截器实际是 匹配任意类任意方法 的一个拦截器。这种拦截器需要在 Module 中声明:

例如
public class MyModule implements Module {
public void loadModule(ApiBinder apiBinder) throws Throwable {
//1.任意类
Matcher<Class<?>> atClass = Matchers.anyClass();
//2.任意方法
Matcher<Method> atMethod = Matchers.anyMethod();
//3.注册拦截器
apiBinder.bindInterceptor(atClass, atMethod, new SimpleInterceptor());
}
}