while (enumeration.hasMoreElements()) {
String url = enumeration.nextElement();
if (!url.endsWith(".jar")) {
continue;
}
WebFragment webFragment = null;
ZipInputStream in = null;
try {
in = new ZipInputStream(bundle.getEntry(url).openStream());
ZipEntry entry;
while ((entry = in.getNextEntry()) != null) {
if (entry.getName().equals("META-INF/web-fragment.xml")) {
webFragment = (WebFragment) JaxbJavaee.unmarshalJavaee(WebFragment.class, in);
break;
}
}
} catch (IOException e) {
logger.error("Fail to parse web-fragment.xml files in jar " + url, e);
throw new DeploymentException("Fail to scan web-fragment.xml files", e);
} catch (ParserConfigurationException e) {
logger.error("Fail to parse web-fragment.xml files in jar " + url, e);
throw new DeploymentException("Fail to scan web-fragment.xml files", e);
} catch (SAXException e) {
logger.error("Fail to parse web-fragment.xml files in jar " + url, e);
throw new DeploymentException("Fail to scan web-fragment.xml files", e);
} catch (JAXBException e) {
logger.error("Fail to parse web-fragment.xml files in jar " + url, e);
throw new DeploymentException("Fail to scan web-fragment.xml files", e);
} finally {
IOUtils.close(in);
}
if (webFragment == null) {
webFragment = new WebFragment();
}
jarUrlWebFragmentDocumentMap.put(url, webFragment);
}
webFragmentEntries = sortWebFragments(earContext, module, bundle, webApp, jarUrlWebFragmentDocumentMap);
} else {
webFragmentEntries = new WebFragmentEntry[0];
}
//
MergeContext mergeContext = new MergeContext();
mergeContext.setEarContext(earContext);
mergeContext.setBundle(bundle);
//Pre-process for annotations
WEB_SERVLET_ANNOTATION_MERGE_HANDLER.preProcessWebXmlElement(webApp, mergeContext);
WEB_FILTER_ANNOTATION_MERGE_HANDLER.preProcessWebXmlElement(webApp, mergeContext);
WEB_LISTENER_ANNOTATION_MERGE_HANDLER.preProcessWebXmlElement(webApp, mergeContext);
SERVLET_SECURITY_ANNOTATION_MERGE_HANDLER.preProcessWebXmlElement(webApp, mergeContext);
//Pre-process each web fragment
for (WebFragmentMergeHandler<WebFragment, WebApp> webFragmentMergeHandler : WEB_FRAGMENT_MERGE_HANDLERS) {
webFragmentMergeHandler.preProcessWebXmlElement(webApp, mergeContext);
}
//Merge the web fragment and annotations to web.xml
for (WebFragmentEntry webFragmentEntry : webFragmentEntries) {
mergeContext.setWebFragmentEntry(webFragmentEntry);
WebFragment webFragment = webFragmentEntry.getWebFragment();
for (WebFragmentMergeHandler<WebFragment, WebApp> webFragmentMergeHandler : WEB_FRAGMENT_MERGE_HANDLERS) {
webFragmentMergeHandler.merge(webFragment, webApp, mergeContext);
}
if (!webFragment.isMetadataComplete()) {
mergeAnnotations(bundle, webApp, mergeContext, webFragmentEntry.getJarURL());
}
}
mergeContext.setWebFragmentEntry(null);
for (WebFragmentMergeHandler<WebFragment, WebApp> webFragmentMergeHandler : WEB_FRAGMENT_MERGE_HANDLERS) {