Search in sources :

Example 1 with J2EEServerInfo

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;
}
Also used : J2EEServerInfo(org.exoplatform.container.monitor.jvm.J2EEServerInfo) MockConfigurationManagerImpl(org.exoplatform.test.MockConfigurationManagerImpl) ConfigurationManagerImpl(org.exoplatform.container.configuration.ConfigurationManagerImpl) MockConfigurationManagerImpl(org.exoplatform.test.MockConfigurationManagerImpl) ConfigurationManager(org.exoplatform.container.configuration.ConfigurationManager) MockServletContext(org.exoplatform.test.MockServletContext) ContainerException(org.exoplatform.container.spi.ContainerException) PrivilegedActionException(java.security.PrivilegedActionException)

Example 2 with J2EEServerInfo

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;
}
Also used : J2EEServerInfo(org.exoplatform.container.monitor.jvm.J2EEServerInfo) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) File(java.io.File) URL(java.net.URL) ConfigurationException(org.exoplatform.container.configuration.ConfigurationException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 3 with J2EEServerInfo

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;
}
Also used : Configuration(org.exoplatform.container.xml.Configuration) J2EEServerInfo(org.exoplatform.container.monitor.jvm.J2EEServerInfo) ConfigurationManagerImpl(org.exoplatform.container.configuration.ConfigurationManagerImpl) MockConfigurationManagerImpl(org.exoplatform.test.MockConfigurationManagerImpl) File(java.io.File)

Aggregations

J2EEServerInfo (org.exoplatform.container.monitor.jvm.J2EEServerInfo)3 File (java.io.File)2 ConfigurationManagerImpl (org.exoplatform.container.configuration.ConfigurationManagerImpl)2 MockConfigurationManagerImpl (org.exoplatform.test.MockConfigurationManagerImpl)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 PrivilegedActionException (java.security.PrivilegedActionException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 ConfigurationException (org.exoplatform.container.configuration.ConfigurationException)1 ConfigurationManager (org.exoplatform.container.configuration.ConfigurationManager)1 ContainerException (org.exoplatform.container.spi.ContainerException)1 Configuration (org.exoplatform.container.xml.Configuration)1 MockServletContext (org.exoplatform.test.MockServletContext)1