跳到主要内容

InvokerFilter形式

例子
public class MyInvokerFilter implements InvokerFilter {
public void doInvoke(Invoker invoker, InvokerChain chain) throws Throwable {
try {
// before
chain.doNext(invoker);
// after
} catch (Throwable e) {
// error
throw e;
}
}
}

最后对拦截器进行声明注册就可以正常使用了。

配置拦截器
public class StartModule extends WebModule {
public void loadModule(WebApiBinder apiBinder) throws Throwable {
...
apiBinder.filter("/*").through(MyInvokerFilter.class); // InvokerFilter形式
...
}
}