@Override
public void scan(JarURLConnection jarConn) throws IOException {
URL url = jarConn.getURL();
URL resourceURL = jarConn.getJarFileURL();
Jar jar = null;
InputStream is = null;
WebXml fragment = new WebXml();
try {
jar = JarFactory.newInstance(url);
is = jar.getInputStream(FRAGMENT_LOCATION);
if (is == null) {
// If there is no web.xml, normal JAR no impact on
// distributable
fragment.setDistributable(true);
} else {
InputSource source = new InputSource(
resourceURL.toString() + "!/" + FRAGMENT_LOCATION);
source.setByteStream(is);
parseWebXml(source, fragment, true);
}
} finally {
if (is != null) {
try {
is.close();
} catch (IOException ioe) {
// Ignore
}
}
if (jar != null) {
jar.close();
}
fragment.setURL(url);
if (fragment.getName() == null) {
fragment.setName(fragment.getURL().toString());
}