try {
InputSource input = new InputSource(url.openStream());
input.setSystemId(url.toString());
digester.parse(input);
} catch (Exception e) {
throw new ConfigException("Error parsing " + url, e);
}
// Parse imported files
Iterator imports = root.getImportConfigs();
ArrayList children = null;
if (imports.hasNext()) {
children = new ArrayList();
while (imports.hasNext()) {
String file = ((ImportConfig)imports.next()).getFile();
URL childURL = null;
try {
if (file.startsWith("/")) {
if (context != null) {
childURL = context.getServletContext().getResource(file);
}
if (childURL == null) {
childURL = getClass().getResource(file);
}
} else {
childURL = new URL(url, file);
}
if (childURL == null) {
throw new ConfigException("Could not find file: '" + file + "'");
}
} catch (MalformedURLException e) {
throw new ConfigException("Bad file path: '" + file + "'", e);
}
children.add(parse(childURL));
}
}