Search in sources :

Example 1 with PortalContainer

use of org.exoplatform.container.PortalContainer in project kernel by exoplatform.

the class ContextManagerListener method requestInitialized.

/**
 * {@inheritDoc}
 */
public void requestInitialized(ServletRequestEvent event) {
    final ExoContainer oldContainer = ExoContainerContext.getCurrentContainerIfPresent();
    ExoContainer container = null;
    boolean hasBeenSet = false;
    try {
        container = getContainer(event);
        if (container == null)
            return;
        if (!container.equals(oldContainer)) {
            if (container instanceof PortalContainer) {
                PortalContainer.setInstance((PortalContainer) container);
            }
            ExoContainerContext.setCurrentContainer(container);
            hasBeenSet = true;
        }
        onRequestInitialized(container, event);
    } finally {
        if (hasBeenSet) {
            if (container instanceof PortalContainer) {
                // Remove the current Portal Container and the current ExoContainer
                PortalContainer.setInstance(null);
            }
            // Re-set the old container
            ExoContainerContext.setCurrentContainer(oldContainer);
        }
    }
}
Also used : ExoContainer(org.exoplatform.container.ExoContainer) PortalContainer(org.exoplatform.container.PortalContainer)

Example 2 with PortalContainer

use of org.exoplatform.container.PortalContainer in project kernel by exoplatform.

the class AbstractHttpSessionListener method sessionCreated.

/**
 * @see javax.servlet.http.HttpSessionListener#sessionCreated(javax.servlet.http.HttpSessionEvent)
 */
public final void sessionCreated(HttpSessionEvent event) {
    final ExoContainer oldContainer = ExoContainerContext.getCurrentContainerIfPresent();
    // Keep the old ClassLoader
    final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
    ExoContainer container = null;
    boolean hasBeenSet = false;
    try {
        container = getContainer(event);
        if (container == null)
            return;
        if (!container.equals(oldContainer)) {
            if (container instanceof PortalContainer) {
                PortalContainer.setInstance((PortalContainer) container);
            }
            ExoContainerContext.setCurrentContainer(container);
            hasBeenSet = true;
        }
        if (requirePortalEnvironment()) {
            final String ctxName = ContainerUtil.getServletContextName(event.getSession().getServletContext());
            if (!PortalContainer.isPortalContainerNameDisabled(ctxName) && container instanceof PortalContainer) {
                if (PortalContainer.getInstanceIfPresent() == null) {
                    // The portal container has not been set
                    PortalContainer.setInstance((PortalContainer) container);
                    hasBeenSet = true;
                }
                // Set the full classloader of the portal container
                Thread.currentThread().setContextClassLoader(((PortalContainer) container).getPortalClassLoader());
            } else {
                if (PropertyManager.isDevelopping()) {
                    LOG.info("The portal environment could not be set for the webapp '" + ctxName + "' because this servlet context has not been defined as a " + "dependency of any portal container or it is a disabled portal" + " container, the sessionCreated event will be ignored");
                }
                return;
            }
        }
        onSessionCreated(container, event);
    } finally {
        if (hasBeenSet) {
            if (container instanceof PortalContainer) {
                // Remove the current Portal Container and the current ExoContainer
                PortalContainer.setInstance(null);
            }
            // Re-set the old container
            ExoContainerContext.setCurrentContainer(oldContainer);
        }
        if (requirePortalEnvironment()) {
            // Re-set the old classloader
            Thread.currentThread().setContextClassLoader(currentClassLoader);
        }
    }
}
Also used : ExoContainer(org.exoplatform.container.ExoContainer) PortalContainer(org.exoplatform.container.PortalContainer)

Example 3 with PortalContainer

use of org.exoplatform.container.PortalContainer in project kernel by exoplatform.

the class TestListenerService method setUp.

public void setUp() throws Exception {
    PortalContainer manager = PortalContainer.getInstance();
    service_ = (ListenerService) manager.getComponentInstanceOfType(ListenerService.class);
}
Also used : PortalContainer(org.exoplatform.container.PortalContainer)

Example 4 with PortalContainer

use of org.exoplatform.container.PortalContainer in project kernel by exoplatform.

the class TestMailService method setUp.

public void setUp() throws Exception {
    PortalContainer pcontainer = PortalContainer.getInstance();
    service = (MailService) pcontainer.getComponentInstanceOfType(MailService.class);
    // starting dummy SMTP Server
    mailServer = new Wiser();
    mailServer.setPort(SMTP_PORT);
    mailServer.start();
}
Also used : Wiser(org.subethamail.wiser.Wiser) PortalContainer(org.exoplatform.container.PortalContainer)

Example 5 with PortalContainer

use of org.exoplatform.container.PortalContainer in project kernel by exoplatform.

the class TestNetService method setUp.

public void setUp() throws Exception {
    if (service_ == null) {
        PortalContainer manager = PortalContainer.getInstance();
        service_ = (NetService) manager.getComponentInstanceOfType(NetService.class);
    }
}
Also used : PortalContainer(org.exoplatform.container.PortalContainer)

Aggregations

PortalContainer (org.exoplatform.container.PortalContainer)24 RootContainer (org.exoplatform.container.RootContainer)9 ExoContainer (org.exoplatform.container.ExoContainer)7 URL (java.net.URL)4 ContainerBuilder (org.exoplatform.container.ContainerBuilder)4 ComponentAdapter (org.exoplatform.container.spi.ComponentAdapter)3 Serializable (java.io.Serializable)1 HashMap (java.util.HashMap)1 ComponentPlugin (org.exoplatform.container.component.ComponentPlugin)1 ConfigurationManager (org.exoplatform.container.configuration.ConfigurationManager)1 SimpleManagementAware (org.exoplatform.container.jmx.support.SimpleManagementAware)1 ManagementContextImpl (org.exoplatform.container.management.ManagementContextImpl)1 PriorityService (org.exoplatform.mocks.PriorityService)1 ExoCacheConfig (org.exoplatform.services.cache.ExoCacheConfig)1 ExoCacheFactoryImpl (org.exoplatform.services.cache.impl.infinispan.ExoCacheFactoryImpl)1 DistributedCacheManager (org.exoplatform.services.ispn.DistributedCacheManager)1 QueueTasks (org.exoplatform.services.scheduler.QueueTasks)1 Task (org.exoplatform.services.scheduler.Task)1 KeyAffinityService (org.infinispan.affinity.KeyAffinityService)1 DistributionManager (org.infinispan.distribution.DistributionManager)1