URL url = jarConn.getURL();
URL resourceURL = jarConn.getJarFileURL();
Jar jar = null;
InputStream is = null;
WebXml fragment = new WebXml();
try {
jar = JarFactory.newInstance(url);
if (parseRequired || context.getXmlValidation()) {
is = jar.getInputStream(FRAGMENT_LOCATION);
}
if (is == null) {
// If there is no web-fragment.xml to process there is no
// impact on distributable
fragment.setDistributable(true);
} else {
InputSource source = new InputSource(
"jar:" + resourceURL.toString() + "!/" +
FRAGMENT_LOCATION);
source.setByteStream(is);
parseWebXml(source, fragment, true);
}
} finally {
if (jar != null) {
jar.close();
}
fragment.setURL(url);
if (fragment.getName() == null) {
fragment.setName(fragment.getURL().toString());
}
fragment.setJarName(extractJarFileName(url));
fragments.put(fragment.getName(), fragment);
}
}