我有一个Filter工厂类,它有两个工厂类和一个缓存实现。如何在Jersey 2中实现ResourceFilterFactory的等效实现?
我的班级定义是
public class CORSResourceFilterFactory implements ResourceFilterFactory {
我有一个create方法,它根据Method类型是否为Options来实现缓存功能。
public List<ResourceFilter> create(AbstractMethod am) {
//Getting the Origin , Methods , Headers and Credentials
if (am.isAnnotationPresent(OPTIONS.class)) {
filters = Collections.<ResourceFilter>singletonList(new CORSOptionsFilter(o, m, h, c));
} else {
filters = Collections.<ResourceFilter>singletonList(new CORSSimpleFilter(o, h, c));
}
filterCache.put(am, filters);
return filters;
}
}
单个过滤器构造函数定义如下:
public CORSOptionsFilter(Collection<String> o, Collection<String> m,
Collection<String> h, boolean c) {
}
public CORSSimpleFilter(Collection<String> o,
Collection<String> h, boolean c) {
}