PortalContainer.setInstance(pcontainer);
executeInitTasks(pcontainer, PortalContainerPreInitTask.TYPE);
// Set the full classloader of the portal container
Thread.currentThread().setContextClassLoader(pcontainer.getPortalClassLoader());
hasChanged = true;
ConfigurationManagerImpl cService = new ConfigurationManagerImpl(pcontainer.getPortalContext(), profiles);
// add configs from services
try
{
cService.addConfiguration(ContainerUtil.getConfigurationURL("conf/portal/configuration.xml"));
}
catch (Exception ex)
{
log.error("Cannot add configuration conf/portal/configuration.xml. ServletContext: " + context, ex);
}
// Add configuration that depends on the environment
String uri;
if (serverenv_.isJBoss())
{
uri = "conf/portal/jboss-configuration.xml";
}
else
{
uri = "conf/portal/generic-configuration.xml";
}
Collection envConf = ContainerUtil.getConfigurationURL(uri);
try
{
cService.addConfiguration(envConf);
}
catch (Exception ex)
{
log.error("Cannot add configuration " + uri + ". ServletContext: " + context, ex);
}
// add configs from web apps
Set<WebAppInitContext> contexts = pcontainer.getWebAppInitContexts();
for (WebAppInitContext webappctx : contexts)
{
ServletContext ctx = webappctx.getServletContext();
try
{
cService.addConfiguration(ctx, "war:/conf/configuration.xml");
}
catch (Exception ex)
{
log.error("Cannot add configuration war:/conf/configuration.xml. ServletContext: " + ctx, ex);
}
}
// add config from application server,
// $AH_HOME/exo-conf/portal/configuration.xml
String overrideConfig =
singleton_.getServerEnvironment().getExoConfigurationDirectory() + "/portal/" + portalContainerName
+ "/configuration.xml";
try
{
File file = new File(overrideConfig);
if (file.exists())
cService.addConfiguration(file.toURI().toURL());
}
catch (Exception ex)
{
log.error("Cannot add configuration " + overrideConfig + ". ServletContext: " + context, ex);
}
cService.processRemoveConfiguration();
ComponentAdapter adapter = pcontainer.registerComponentInstance(ConfigurationManager.class, cService);
pcontainer.initContainer();
registerComponentInstance(portalContainerName, pcontainer);
pcontainer.start();