use of com.alipay.sofa.rpc.filter.ExcludeFilter in project sofa-boot by alipay.
the class RpcBindingConverter method parseFilter.
protected void parseFilter(Element element, RpcBindingParam param, BindingConverterContext bindingConverterContext) {
List<Filter> filters = new ArrayList<Filter>(RpcFilterContainer.getInstance().getFilters(bindingConverterContext.getApplicationContext()));
if (element != null) {
List<String> filterNames = new ArrayList<String>();
String filterStrs = element.getAttribute(RpcBindingXmlConstants.TAG_FILTER);
if (StringUtils.hasText(filterStrs)) {
String[] subFilter = filterStrs.split(FILTER_SEPERATOR_SYMBOL);
for (String subfilterName : subFilter) {
if (StringUtils.hasText(subfilterName)) {
if (subfilterName.charAt(0) == EXCLUDE_FILTER_BEGIN_SYMBOL) {
String realFilterName = subfilterName.substring(1);
if (StringUtils.hasText(realFilterName)) {
filters.add(new ExcludeFilter(realFilterName));
}
} else {
filterNames.add(subfilterName);
}
}
}
}
if (!CollectionUtils.isEmpty(filterNames)) {
for (String filterName : filterNames) {
Object filter = bindingConverterContext.getApplicationContext().getBean(filterName);
if (filter instanceof Filter) {
filters.add((Filter) filter);
} else {
throw new SofaBootRpcRuntimeException("filter name[" + filterName + "] is not ref a Filter.");
}
}
}
}
param.setFilters(filters);
}
use of com.alipay.sofa.rpc.filter.ExcludeFilter in project sofa-boot by sofastack.
the class RpcBindingConverter method parseFilter.
protected void parseFilter(Element element, RpcBindingParam param, BindingConverterContext bindingConverterContext) {
List<Filter> filters = new ArrayList<Filter>(RpcFilterContainer.getInstance().getFilters(bindingConverterContext.getApplicationContext()));
if (element != null) {
List<String> filterNames = new ArrayList<String>();
String filterStrs = element.getAttribute(RpcBindingXmlConstants.TAG_FILTER);
if (StringUtils.hasText(filterStrs)) {
String[] subFilter = filterStrs.split(FILTER_SEPERATOR_SYMBOL);
for (String subfilterName : subFilter) {
if (StringUtils.hasText(subfilterName)) {
if (subfilterName.charAt(0) == EXCLUDE_FILTER_BEGIN_SYMBOL) {
String realFilterName = subfilterName.substring(1);
if (StringUtils.hasText(realFilterName)) {
filters.add(new ExcludeFilter(realFilterName));
}
} else {
filterNames.add(subfilterName);
}
}
}
}
if (!CollectionUtils.isEmpty(filterNames)) {
for (String filterName : filterNames) {
Object filter = bindingConverterContext.getApplicationContext().getBean(filterName);
if (filter instanceof Filter) {
filters.add((Filter) filter);
} else {
throw new SofaBootRpcRuntimeException("filter name[" + filterName + "] is not ref a Filter.");
}
}
}
}
param.setFilters(filters);
}
Aggregations