目录
Filter接口
Filter接口提供了一个invoke方法和一个是Listener接口。
其中invoke方法用于定义Filter中请求相关的处理逻辑。Listener接口有onResponse,onError两个方法,这两个方法用于定义Filter中响应相关的处理逻辑。
public interface Filter {
/**
* Make sure call invoker.invoke() in your implementation.
*/
Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException;
interface Listener {
void onResponse(Result appResponse, Invoker<?> invoker, Invocation invocation);
void onError(Throwable t, Invoker<?> invoker, Invocation invocation);
}
}
ListenableFilter
ListenableFilter是Dubbo中实现的一个Filter接口的抽象类。抽象类的存在一般就是为了对接口进行增强,ListenableFilter内置了一个Invocation为key,Listener接口实例为value的Map。
public abstract class ListenableFilter implements Filter {
protected Listener listener = null;
protected final ConcurrentMap<Inv