public void configure(Configuration config) throws ConfigurationException {
this.checkReload = config.getAttributeAsBoolean("check-reload", true);
// Obtain the configuration file, or use the XCONF_URL if none
// is defined
String xconfURL = config.getAttribute("config", XCONF_URL);
// Reload check delay. Default is 1 second.
this.lastModifiedDelay = config.getChild("reload").getAttributeAsLong("delay", 1000L);
String fileName = config.getAttribute("file", "sitemap.xmap");
try {
this.source = new DelayedRefreshSourceWrapper(this.resolver.resolveURI(fileName), this.lastModifiedDelay);
} catch (Exception e) {
throw new ConfigurationException("Cannot resolve " + fileName, e);
}
// Read the builtin languages definition file
Configuration builtin;
try {
Source source = this.resolver.resolveURI(xconfURL);
try {
Settings settings = SettingsHelper.getSettings(this.context);
SAXConfigurationHandler handler = new PropertyAwareSAXConfigurationHandler(settings, this.getLogger());
SourceUtil.toSAX( this.manager, source, null, handler);
builtin = handler.getConfiguration();
} finally {
this.resolver.release(source);
}
} catch(Exception e) {
String msg = "Error while reading " + xconfURL + ": " + e.getMessage();
throw new ConfigurationException(msg, e);
}
// Create a selector for tree builders of all languages
this.builderSelector = new ExtendedComponentSelector(Thread.currentThread().getContextClassLoader());
try {
LifecycleHelper.setupComponent(this.builderSelector,
this.getLogger(),
this.context,
this.manager,
this.roleManager,
builtin);
} catch (ConfigurationException e) {
throw e;
} catch (Exception e) {
throw new ConfigurationException("Could not setup builder selector", e);
}
}
|