* Creates a <code>CatalogManager</code>, used to resolve DTDs and other entities.
*
* @return A <code>CatalogManager</code> to be used for resolving DTDs and other entities.
*/
protected CatalogManager createCatalogManager() {
CatalogManager manager = new CatalogManager();
manager.setIgnoreMissingProperties(true);
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
StringBuffer builder = new StringBuffer();
boolean first = true;
for (int i = 0; i < catalogs.length; i++) {
final String catalog = catalogs[i];
try {
Enumeration enumeration = classLoader.getResources(catalog);
while (enumeration.hasMoreElements()) {
if (!first) {
builder.append(';');
} else {
first = false;
}
URL resource = (URL) enumeration.nextElement();
builder.append(resource.toExternalForm());
}
} catch (IOException ioe) {
getLog().warn("Failed to search for catalog files: " + catalog);
// Let's be a little tolerant here.
}
}
String catalogFiles = builder.toString();
if (catalogFiles.length() == 0) {
getLog().warn("Failed to find catalog files.");
} else {
if (getLog().isDebugEnabled()) {
getLog().debug("Catalogs to load: "+catalogFiles);
}
manager.setCatalogFiles(catalogFiles);
}
return manager;
}