FilterMergeHandler.addFilter(newFilter, mergeContext);
}
//filter-mapping configured in web.xml and web-fragment.xml will override the configurations from annotation
if (!FilterMappingMergeHandler.isFilterMappingConfigured(filterName, mergeContext)) {
//create filter-mapping element
FilterMapping filterMapping = new FilterMapping();
filterMapping.setFilterName(filterName);
for (String servletName : webFilter.servletNames()) {
filterMapping.getServletName().add(servletName);
}
for (DispatcherType dispatcherType : webFilter.dispatcherTypes()) {
filterMapping.getDispatcher().add(Dispatcher.fromValue(dispatcherType.name()));
}
for (String urlPattern : urlPatterns) {
filterMapping.getUrlPattern().add(urlPattern);
}
webApp.getFilterMapping().add(filterMapping);
FilterMappingMergeHandler.addFilterMapping(filterMapping, mergeContext);
//Set this tag, so that if any following web-fragment.xml has defined the url-patterns explicitly, it could drop the configurations from annotation
mergeContext.setAttribute(FilterMappingMergeHandler.createFilterMappingSourceKey(filterName), ElementSource.ANNOTATION);