public void configure(Configuration sconf) throws ConfigurationException {
super.configure(sconf);
this.sitemapFileName = sconf.getAttribute("file");
boolean checkReload = sconf.getAttributeAsBoolean("check-reload", true);
boolean reloadAsynchron = sconf.getAttributeAsBoolean("reload-method", false);
long checkDelay = sconf.getAttributeAsLong("check-delay", 1L) * 1000;
if (this.getLogger().isDebugEnabled()) {
getLogger().debug("Sitemap location = " + this.sitemapFileName);
getLogger().debug("Checking sitemap reload = " + checkReload);
getLogger().debug("Reloading sitemap asynchron = " + reloadAsynchron);
getLogger().debug("Sitemap check delay = " + checkDelay + " sec");
}
// Read sitemap roles
Parser p = null;
Configuration rolesConfig;
try {
p = (Parser)this.manager.lookup(Parser.ROLE);
SAXConfigurationHandler b = new SAXConfigurationHandler();
InputStream inputStream = ClassUtils.getResource("org/apache/cocoon/sitemap/sitemap.roles").openStream();
InputSource is = new InputSource(inputStream);
is.setSystemId("org/apache/cocoon/sitemap/sitemap.roles");
p.parse(is, b);
rolesConfig = b.getConfiguration();
} catch (Exception e) {
getLogger().error("Could not configure Cocoon environment", e);
throw new ConfigurationException("Error trying to load configurations", e);
} finally {
this.manager.release(p);
}
DefaultRoleManager sitemapRoleManager = new DefaultRoleManager();
sitemapRoleManager.setLogger(getLogger());
sitemapRoleManager.configure(rolesConfig);
AbstractSitemap.setRoleManager(sitemapRoleManager, sconf);
AbstractSitemap.setLogKitManager(this.sitemapLogKitManager);
try {
sitemapHandler = createHandler(this.manager, this.sitemapFileName, checkReload, reloadAsynchron, checkDelay);
} catch (Exception e) {
throw new ConfigurationException("Failed to create sitemap handler", e);
}
}
|