use of com.weibo.api.motan.rpc.Response in project motan by weibocom.
the class ProtocolFilterDecorator method decorateWithFilter.
private <T> Provider<T> decorateWithFilter(Provider<T> provider, URL url) {
List<Filter> filters = getFilters(url, MotanConstants.NODE_TYPE_SERVICE);
if (filters == null || filters.size() == 0) {
return provider;
}
Provider<T> lastProvider = provider;
for (Filter filter : filters) {
final Filter f = filter;
final Provider<T> lp = lastProvider;
lastProvider = new Provider<T>() {
@Override
public Response call(Request request) {
return f.filter(lp, request);
}
@Override
public String desc() {
return lp.desc();
}
@Override
public void destroy() {
lp.destroy();
}
@Override
public Class<T> getInterface() {
return lp.getInterface();
}
@Override
public URL getUrl() {
return lp.getUrl();
}
@Override
public void init() {
lp.init();
}
@Override
public boolean isAvailable() {
return lp.isAvailable();
}
};
}
return lastProvider;
}
Aggregations