for (WebXml fragment : fragments) {
URL url = fragment.getURL();
JarInputStream jarInputStream = null;
InputStream is = null;
ServletContainerInitializer sci = null;
try {
if ("jar".equals(url.getProtocol())) {
JarURLConnection jarConn =
(JarURLConnection) url.openConnection();
URL resourceURL = jarConn.getJarFileURL();
URLConnection resourceConn = resourceURL.openConnection();
resourceConn.setUseCaches(false);
jarInputStream =
new JarInputStream(resourceConn.getInputStream());
JarEntry entry = jarInputStream.getNextJarEntry();
while (entry != null) {
if (SCI_LOCATION.equals(entry.getName())) {
break;
}
entry = jarInputStream.getNextJarEntry();
}
if (entry != null) {
is = jarInputStream;
}
} else if ("file".equals(url.getProtocol())) {
String path = url.getPath();
File file = new File(path, SCI_LOCATION);
if (file.exists()) {
is = new FileInputStream(file);
}
}
if (is != null) {
sci = getServletContainerInitializer(is);
}
} catch (IOException ioe) {
log.error(sm.getString(
"contextConfig.servletContainerInitializerFail", url,
context.getName()));
ok = false;
return;
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
// Ignore
}
}
if (jarInputStream != null) {
try {
jarInputStream.close();
} catch (IOException e) {
// Ignore
}
}
}
if (sci == null) {
continue;
}
initializerClassMap.put(sci, new HashSet<Class<?>>());
HandlesTypes ht =
sci.getClass().getAnnotation(HandlesTypes.class);
if (ht != null) {
Class<?>[] types = ht.value();
if (types != null) {
for (Class<?> type : types) {
Set<ServletContainerInitializer> scis =