*
* @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().getChildLogger("manager"));
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
// first check for deprecated property to be compatible:
String parser = System.getProperty(Constants.DEPRECATED_PARSER_PROPERTY, Constants.DEFAULT_PARSER);
if ( !Constants.DEFAULT_PARSER.equals( parser ) ) {
this.getLogger().warn("Deprecated property " +Constants.DEPRECATED_PARSER_PROPERTY+ " is used. Please use "+Constants.PARSER_PROPERTY+" instead.");
if ( "org.apache.cocoon.components.parser.XercesParser".equals(parser) ) {
parser = "org.apache.avalon.excalibur.xml.XercesParser";
} else {
this.getLogger().warn("Unknown value for deprecated property: " +
Constants.DEPRECATED_PARSER_PROPERTY + ", value: " + parser +
". If you experience problems during startup, check the parser configuration section of the documentation.");
}
} else {
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().getChildLogger("startup"));
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);
}
if (getLogger().isDebugEnabled()) {
getLogger().debug("Classpath = " + classpath);
getLogger().debug("Work directory = " + workDir.getCanonicalPath());
}
startupManager.initialize();
this.configure(startupManager);
startupManager.dispose();
startupManager = null;
this.componentManager.initialize();
// Get the Processor and keep it if it's ThreadSafe