public void initialize() throws Exception {
try {
DefaultContext appContext = new DefaultContext();
appContext.put(Constants.CONTEXT_CLASS_LOADER, Main.class.getClassLoader());
cliContext = new CommandLineContext(contextDir);
cliContext.enableLogging(new LogKitLogger(log));
appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, cliContext);
DefaultLogKitManager logKitManager = null;
if (logKit != null) {
final FileInputStream fis = new FileInputStream(logKit);
final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
final Configuration logKitConf = builder.build(fis);
logKitManager = new DefaultLogKitManager(Hierarchy.getDefaultHierarchy());
logKitManager.setLogger(log);
final DefaultContext subcontext = new DefaultContext(appContext);
subcontext.put("context-root", contextDir);
logKitManager.contextualize(subcontext);
logKitManager.configure(logKitConf);
if (logger != null) {
log = logKitManager.getLogger(logger);
} else {
log = logKitManager.getLogger("cocoon");
}
} else {
logKitManager = new DefaultLogKitManager(Hierarchy.getDefaultHierarchy());
logKitManager.setLogger(log);
}
appContext.put(Constants.CONTEXT_CLASSPATH, getClassPath(contextDir));
appContext.put(Constants.CONTEXT_WORK_DIR, work);
appContext.put(Constants.CONTEXT_UPLOAD_DIR, contextDir + "upload-dir");
File cacheDir = getDir(workDir + File.separator + "cache-dir", "cache");
appContext.put(Constants.CONTEXT_CACHE_DIR, cacheDir);
appContext.put(Constants.CONTEXT_CONFIG_URL, conf.toURL());
loadClasses(classList);
cocoon = new Cocoon();
cocoon.enableLogging(new LogKitLogger(log));
cocoon.contextualize(appContext);
cocoon.setLogKitManager(logKitManager);
cocoon.initialize();
if (brokenLinkFileName != null) {