}
public void addFilter(WebFilter webFilter, String filterClassName)
throws Exception
{
FilterMapping config = new FilterMapping();
config.setFilterManager(_filterManager);
config.setFilterClass(filterClassName);
String filterName = webFilter.filterName();
if ("".equals(filterName))
filterName = filterClassName;
config.setFilterName(filterName);
boolean isMapping = false;
if (webFilter.value().length > 0) {
FilterMapping.URLPattern urlPattern = config.createUrlPattern();
for (String url : webFilter.value())
urlPattern.addText(url);
urlPattern.init();
isMapping = true;
}
if (webFilter.urlPatterns().length > 0) {
FilterMapping.URLPattern urlPattern = config.createUrlPattern();
for (String url : webFilter.urlPatterns()) {
urlPattern.addText(url);
}
urlPattern.init();
isMapping = true;
}
if (webFilter.servletNames().length > 0) {
for (String servletName : webFilter.servletNames())
config.addServletName(servletName);
isMapping = true;
}
if (! isMapping) {
throw new ConfigException(L.l("Annotation @WebFilter at '{0}' must specify either value, urlPatterns or servletNames", filterClassName));
}
for (WebInitParam initParam : webFilter.initParams())
config.setInitParam(initParam.name(), initParam.value());
for (DispatcherType dispatcher : webFilter.dispatcherTypes())
config.addDispatcher(dispatcher);
config.setAsyncSupported(webFilter.asyncSupported());
addFilterMapping(config);
}