use of org.apache.naming.resources.DirContextURLConnection in project tomcat70 by apache.
the class ContextConfig method processAnnotationsJndi.
protected void processAnnotationsJndi(URL url, WebXml fragment, boolean handlesTypesOnly) {
try {
URLConnection urlConn = url.openConnection();
DirContextURLConnection dcUrlConn;
if (!(urlConn instanceof DirContextURLConnection)) {
// This should never happen
sm.getString("contextConfig.jndiUrlNotDirContextConn", url);
return;
}
dcUrlConn = (DirContextURLConnection) urlConn;
dcUrlConn.setUseCaches(false);
String type = dcUrlConn.getHeaderField(ResourceAttributes.TYPE);
if (ResourceAttributes.COLLECTION_TYPE.equals(type)) {
// Collection
Enumeration<String> dirs = dcUrlConn.list();
if (log.isDebugEnabled() && dirs.hasMoreElements()) {
log.debug(sm.getString("contextConfig.processAnnotationsWebDir.debug", url));
}
while (dirs.hasMoreElements()) {
String dir = dirs.nextElement();
URL dirUrl = new URL(url.toString() + '/' + dir);
processAnnotationsJndi(dirUrl, fragment, handlesTypesOnly);
}
} else {
// Single file
if (url.getPath().endsWith(".class")) {
InputStream is = null;
try {
is = dcUrlConn.getInputStream();
processAnnotationsStream(is, fragment, handlesTypesOnly);
} catch (IOException e) {
log.error(sm.getString("contextConfig.inputStreamJndi", url), e);
} catch (ClassFormatException e) {
log.error(sm.getString("contextConfig.inputStreamJndi", url), e);
} finally {
if (is != null) {
try {
is.close();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
}
}
}
}
}
} catch (IOException e) {
log.error(sm.getString("contextConfig.jndiUrl", url), e);
}
}
Aggregations