Search in sources :

Example 11 with PortalContainer

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

the class QueueTaskJob method execute.

public void execute(JobContext context) throws Exception {
    PortalContainer manager = PortalContainer.getInstance();
    QueueTasks qtasks = (QueueTasks) manager.getComponentInstanceOfType(QueueTasks.class);
    Task task = qtasks.poll();
    while (task != null) {
        try {
            task.execute();
        } catch (Exception ex) {
            LOG.error(ex.getLocalizedMessage(), ex);
        }
        task = qtasks.poll();
    }
}
Also used : Task(org.exoplatform.services.scheduler.Task) QueueTasks(org.exoplatform.services.scheduler.QueueTasks) PortalContainer(org.exoplatform.container.PortalContainer)

Example 12 with PortalContainer

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

the class TestAsynchronousListener method setUp.

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

Example 13 with PortalContainer

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

the class InitialContextTest method setUp.

public void setUp() throws Exception {
    PortalContainer container = PortalContainer.getInstance();
    initializer = (InitialContextInitializer) container.getComponentInstanceOfType(InitialContextInitializer.class);
    assertNotNull(initializer);
}
Also used : PortalContainer(org.exoplatform.container.PortalContainer)

Example 14 with PortalContainer

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

the class TestSchedulerService method setUp.

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

Example 15 with PortalContainer

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

the class TestSchedulerService method testMultiplePortalContainers.

public void testMultiplePortalContainers() throws Exception {
    ExoContainer oldContainer = ExoContainerContext.getCurrentContainerIfPresent();
    MyComponent component;
    PortalContainer container = null;
    MyComponent component2;
    PortalContainer container2 = null;
    String oldProfileList = System.getProperty(PropertyManager.RUNTIME_PROFILES);
    try {
        try {
            PropertyManager.setProperty(PropertyManager.RUNTIME_PROFILES, "MultiplePortalContainers");
            component = (MyComponent) (container = RootContainer.getInstance().getPortalContainer("portal-container")).getComponentInstanceOfType(MyComponent.class);
        } finally {
            ExoContainerContext.setCurrentContainer(oldContainer);
        }
        try {
            PropertyManager.setProperty(PropertyManager.RUNTIME_PROFILES, "MultiplePortalContainers,portal-container2");
            component2 = (MyComponent) (container2 = RootContainer.getInstance().getPortalContainer("portal-container2")).getComponentInstanceOfType(MyComponent.class);
            Thread.sleep(2000);
        } finally {
            ExoContainerContext.setCurrentContainer(oldContainer);
        }
    } finally {
        if (oldProfileList == null) {
            System.clearProperty(PropertyManager.RUNTIME_PROFILES);
        } else {
            System.setProperty(PropertyManager.RUNTIME_PROFILES, oldProfileList);
        }
        PropertyManager.refresh();
    }
    assertEquals("myJob1", component.name);
    assertEquals(container, component.container);
    assertTrue(component.endRequest > 0);
    assertFalse(component.endRequestFailed);
    assertEquals("myJob2", component2.name);
    assertEquals(container2, component2.container);
    assertTrue(component2.endRequest > 0);
    assertFalse(component2.endRequestFailed);
}
Also used : ExoContainer(org.exoplatform.container.ExoContainer) 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