void addFilterMapping(WebAppFilterMapping mapping)
throws WebAppConfigurationException {
String filterName = mapping.getFilterName();
if (filterName == null) {
throw new WebAppConfigurationException(
"No filter-name in filter-mapping");
}
if (mapping.getServletNames() == null && mapping.getUrlPatterns() == null) {
throw new WebAppConfigurationException(
"No servlet-name or url-pattern element");
}
FilterInfo info = filterNameToInfo.get(filterName);
if (info == null) {
LOGGER.severe("Error: Could not find filter-name '" + filterName + "'");
return;
}
if (!info.initialized) { // should never happen
LOGGER.severe("Error: Filter not initialized '" + filterName + "'");
return;
}
if (mapping.getServletNames() != null) {
for (String servletName : mapping.getServletNames()) {
if (servletName.equals("*")) {
addFilterMappingForAllServlets(info, mapping);
} else if (!servletNameToInfo.containsKey(servletName)) {
throw new WebAppConfigurationException(
"Unknown servlet-name '" + servletName + "'");
} else {
addFilterMappingForOneServlet(info, servletName, mapping);
}
}