Search in sources :

Example 1 with MockConfigurationManagerImpl

use of org.exoplatform.test.MockConfigurationManagerImpl 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)

Aggregations

PrivilegedActionException (java.security.PrivilegedActionException)1 ConfigurationManager (org.exoplatform.container.configuration.ConfigurationManager)1 ConfigurationManagerImpl (org.exoplatform.container.configuration.ConfigurationManagerImpl)1 J2EEServerInfo (org.exoplatform.container.monitor.jvm.J2EEServerInfo)1 ContainerException (org.exoplatform.container.spi.ContainerException)1 MockConfigurationManagerImpl (org.exoplatform.test.MockConfigurationManagerImpl)1 MockServletContext (org.exoplatform.test.MockServletContext)1