@Override
public void merge(WebFragment webFragment, WebApp webApp, MergeContext mergeContext) throws DeploymentException {
for (ServletMapping srcServletMapping : webFragment.getServletMapping()) {
String servletName = srcServletMapping.getServletName();
ServletMapping targetServletMapping = (ServletMapping) mergeContext.getAttribute(createServletMappingKey(servletName));
if (targetServletMapping == null) {
webApp.getServletMapping().add(srcServletMapping);
mergeContext.setAttribute(createServletMappingKey(servletName), srcServletMapping);
for (SubMergeHandler<ServletMapping, ServletMapping> subMergeHandler : subMergeHandlers) {
subMergeHandler.add(srcServletMapping, mergeContext);
}
} else {
//If the servlet-mapping is configured in the central web.xml file, all the configurations from the fragment xml and annotations are ignored
if(isServletMappingFromWebXml(servletName, mergeContext)) {
continue;
}
if (isServletMappingFromAnnotation(servletName, mergeContext) && !srcServletMapping.getUrlPattern().isEmpty()) {
//If the current url-patterns configurations are from annotations, so let's drop them
targetServletMapping.getUrlPattern().clear();
mergeContext.removeAttribute(createServletMappingSourceKey(servletName));
}
for (SubMergeHandler<ServletMapping, ServletMapping> subMergeHandler : subMergeHandlers) {
subMergeHandler.merge(srcServletMapping, targetServletMapping, mergeContext);
}