use of org.exoplatform.container.monitor.jvm.J2EEServerInfo in project kernel by exoplatform.
the class RootContainer method getPortalContainer.
public PortalContainer getPortalContainer(final String name) {
PortalContainer pcontainer = getComponentInstance(name, PortalContainer.class);
if (pcontainer == null) {
J2EEServerInfo senv = getServerEnvironment();
if ("standalone".equals(senv.getServerName()) || "test".equals(senv.getServerName())) {
try {
MockServletContext scontext = new MockServletContext(name);
pcontainer = new PortalContainer(this, scontext);
final PortalContainer currentPortalContainer = pcontainer;
SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>() {
public Void run() {
PortalContainer.setInstance(currentPortalContainer);
return null;
}
});
final ConfigurationManagerImpl cService = new MockConfigurationManagerImpl(scontext);
cService.addConfiguration(ContainerUtil.getConfigurationURL("conf/portal/configuration.xml"));
cService.addConfiguration(ContainerUtil.getConfigurationURL("conf/portal/test-configuration.xml"));
cService.processRemoveConfiguration();
SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>() {
public Void run() {
currentPortalContainer.registerComponentInstance(ConfigurationManager.class, cService);
registerComponentInstance(name, currentPortalContainer);
currentPortalContainer.start(true);
onStartupComplete();
return null;
}
});
} catch (Exception ex) {
LOG.error(ex.getLocalizedMessage(), ex);
}
}
}
return pcontainer;
}
use of org.exoplatform.container.monitor.jvm.J2EEServerInfo in project kernel by exoplatform.
the class StandaloneContainer method getConfigurationURL.
/**
* Gives the configuration URL according to the given {@link ClassLoader}
*/
private static URL getConfigurationURL(ClassLoader configClassLoader) throws MalformedURLException {
final J2EEServerInfo env = new J2EEServerInfo();
// (2) exo-configuration.xml in AS (standalone) home directory
URL configurationURL = SecurityHelper.doPrivilegedMalformedURLExceptionAction(new PrivilegedExceptionAction<URL>() {
public URL run() throws Exception {
return (new File(env.getServerHome() + "/exo-configuration.xml")).toURI().toURL();
}
});
// (3) AS_HOME/conf/exo-conf (JBossAS usecase)
if (!fileExists(configurationURL)) {
configurationURL = SecurityHelper.doPrivilegedMalformedURLExceptionAction(new PrivilegedExceptionAction<URL>() {
public URL run() throws Exception {
return (new File(env.getExoConfigurationDirectory() + "/exo-configuration.xml")).toURI().toURL();
}
});
}
// (4) conf/exo-configuration.xml in war/ear(?)
if (!fileExists(configurationURL) && configClassLoader != null) {
configurationURL = configClassLoader.getResource("conf/exo-configuration.xml");
}
return configurationURL;
}
use of org.exoplatform.container.monitor.jvm.J2EEServerInfo in project kernel by exoplatform.
the class RootContainer method loadConfigurationManager.
/**
* @param rootContainer
* @return
* @throws Exception
*/
private static ConfigurationManager loadConfigurationManager(RootContainer rootContainer, boolean logEnabled) throws Exception {
final ConfigurationManagerImpl service = new ConfigurationManagerImpl(rootContainer.profiles, logEnabled);
service.addConfiguration(ContainerUtil.getConfigurationURL("conf/configuration.xml"));
if (System.getProperty("maven.exoplatform.dir") != null) {
service.addConfiguration(ContainerUtil.getConfigurationURL("conf/test-configuration.xml"));
}
J2EEServerInfo serverEnv = rootContainer.getServerEnvironment();
service.addConfiguration(Archive.getConfigurationURL(serverEnv.getApplicationDeployDirectories(), serverEnv.getApplicationDeployArchives(), "META-INF/exo-conf/configuration.xml"));
String confDir = serverEnv.getExoConfigurationDirectory();
String overrideConf = confDir + "/configuration.xml";
File file = new File(overrideConf);
if (PrivilegedFileHelper.exists(file)) {
service.addConfiguration("file:" + overrideConf);
}
service.processRemoveConfiguration();
if (PropertyManager.isDevelopping()) {
Configuration conf = service.getConfiguration();
if (conf != null) {
conf.keepCurrentState();
}
}
return service;
}
Aggregations