*
* @exception Exception if an error occurs
*/
public void initialize() throws Exception {
if (parentComponentManager != null) {
this.componentManager = new ExcaliburComponentManager(parentComponentManager,(ClassLoader)this.context.get(Constants.CONTEXT_CLASS_LOADER));
} else {
this.componentManager = new ExcaliburComponentManager((ClassLoader)this.context.get(Constants.CONTEXT_CLASS_LOADER));
}
this.componentManager.setLogger(getLogger());
this.componentManager.contextualize(this.context);
if (getLogger().isDebugEnabled()) {
getLogger().debug("New Cocoon object.");
}
// Log the System Properties.
dumpSystemProperties();
// Setup the default parser, for parsing configuration.
// If one need to use a different parser, set the given system property
String parser = System.getProperty(Constants.PARSER_PROPERTY, Constants.DEFAULT_PARSER);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Using parser: " + parser);
}
ExcaliburComponentManager startupManager = new ExcaliburComponentManager((ClassLoader)this.context.get(Constants.CONTEXT_CLASS_LOADER));
startupManager.setLogger(getLogger());
startupManager.contextualize(this.context);
startupManager.setLogKitManager(this.logKitManager);
try {
startupManager.addComponent(Parser.ROLE, ClassUtils.loadClass(parser), new org.apache.avalon.framework.configuration.DefaultConfiguration("", "empty"));
} catch (Exception e) {
getLogger().error("Could not load parser, Cocoon object not created.", e);
throw new ConfigurationException("Could not load parser " + parser, e);
}
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Creating Repository with this directory: " + this.workDir);
}
FilesystemStore repository = new FilesystemStore();
repository.setLogger(getLogger());
repository.setDirectory(this.workDir);
this.componentManager.addComponentInstance(Store.ROLE + "/Filesystem", repository);
} catch (IOException e) {
getLogger().error("Could not create repository!", e);
throw new ConfigurationException("Could not create the repository!", e);
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Classpath = " + classpath);
getLogger().debug("Work directory = " + workDir.getCanonicalPath());
}
startupManager.initialize();
Configuration conf = this.configure(startupManager);
startupManager.dispose();
startupManager = null;
this.componentManager.initialize();
// Get the Processor and keep it if it's ThreadSafe