protected FilterMapping addFilterMapping(WebApp webApp, String filterName,
String mappingValue, FilterMappingType mappingType,
FilterMappingDispatcher mappingDispatcher) throws IOException {
FilterMapping mapping = (FilterMapping) createBean(webApp, "FilterMapping");
mapping.setFilterName(filterName);
switch(mappingType){
case SERVLET_NAME:
mapping.setServletName(mappingValue);
break;
case URL_PATTERN:
mapping.setUrlPattern(mappingValue);
break;
default:
throw new IllegalArgumentException("Not supported filter " +
"mapping type");
}
try {
mapping.setDispatcher(new String[] {mappingDispatcher.toString()});
} catch (VersionNotSupportedException ve){
log.warning(ve.getMessage());
}
webApp.addFilterMapping(mapping);