if (clazz.isAnnotationPresent(WebFilter.class)) {
WebFilter annotation = clazz.getAnnotation(WebFilter.class);
// Add servlet filter
String filterName = annotation.filterName();
FilterDef filterDef = new FilterDef();
filterDef.setFilterName(annotation.filterName());
filterDef.setFilterClass(clazz.getName());
WebInitParam[] params = annotation.initParams();
for (int i = 0; i < params.length; i++) {
filterDef.addInitParameter(params[i].name(), params[i].value());
}
context.addFilterDef(filterDef);
FilterMap filterMap = new FilterMap();
filterMap.setFilterName(filterName);
String[] urlPatterns = annotation.urlPatterns();