use of com.weibo.api.motan.core.extension.Activation in project motan by weibocom.
the class ProtocolFilterDecorator method decorateWithFilter.
private <T> Referer<T> decorateWithFilter(Referer<T> referer, URL url) {
List<Filter> filters = getFilters(url, MotanConstants.NODE_TYPE_REFERER);
Referer<T> lastRef = referer;
for (Filter filter : filters) {
final Filter f = filter;
final Referer<T> lf = lastRef;
lastRef = new Referer<T>() {
@Override
public Response call(Request request) {
Activation activation = f.getClass().getAnnotation(Activation.class);
if (activation != null && !activation.retry() && request.getRetries() != 0) {
return lf.call(request);
}
return f.filter(lf, request);
}
@Override
public String desc() {
return lf.desc();
}
@Override
public void destroy() {
lf.destroy();
}
@Override
public Class<T> getInterface() {
return lf.getInterface();
}
@Override
public URL getUrl() {
return lf.getUrl();
}
@Override
public void init() {
lf.init();
}
@Override
public boolean isAvailable() {
return lf.isAvailable();
}
@Override
public int activeRefererCount() {
return lf.activeRefererCount();
}
@Override
public URL getServiceUrl() {
return lf.getServiceUrl();
}
};
}
return lastRef;
}
Aggregations