for (WebXml fragment : fragments) {
URL url = fragment.getURL();
JarFile jarFile = null;
InputStream is = null;
ServletContainerInitializer sci = null;
try {
if ("jar".equals(url.getProtocol())) {
JarURLConnection conn =
(JarURLConnection) url.openConnection();
jarFile = conn.getJarFile();
ZipEntry entry = jarFile.getEntry(SCI_LOCATION);
if (entry != null) {
is = jarFile.getInputStream(entry);
}
} 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 (jarFile != null) {
try {
jarFile.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 =