Search in sources :

Example 21 with PortalContainer

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

the class TestManagementProvider method testContainerScopedRegistration.

public void testContainerScopedRegistration() {
    URL rootURL = getClass().getResource("root-configuration.xml");
    URL portal1URL = getClass().getResource("portal-configuration1.xml");
    URL portal2URL = getClass().getResource("portal-configuration2.xml");
    RootContainer root = new ContainerBuilder().withRoot(rootURL).withPortal("portal1", portal1URL).withPortal("portal2", portal2URL).build();
    Foo fooRoot = (Foo) root.getComponentInstanceOfType(Foo.class);
    ManagementProviderImpl provider = (ManagementProviderImpl) root.getComponentInstanceOfType(ManagementProviderImpl.class);
    PortalContainer portal1 = root.getPortalContainer("portal1");
    Foo fooPortal1 = (Foo) portal1.getComponentInstanceOfType(Foo.class);
    ManagementProviderImpl provider1 = (ManagementProviderImpl) portal1.getComponentInstanceOfType(ManagementProviderImpl.class);
    PortalContainer portal2 = root.getPortalContainer("portal2");
    Foo fooPortal2 = (Foo) portal2.getComponentInstanceOfType(Foo.class);
    ManagementProviderImpl provider2 = (ManagementProviderImpl) portal2.getComponentInstanceOfType(ManagementProviderImpl.class);
    // 
    assertEquals(6, provider.managedResources.size());
    assertTrue(provider.resources.contains(root));
    assertTrue(provider.resources.contains(root));
    assertTrue(provider.resources.contains(portal1));
    assertTrue(provider.resources.contains(portal2));
    assertTrue(provider.resources.contains(fooRoot));
    assertTrue(provider.resources.contains(fooPortal1));
    assertTrue(provider.resources.contains(fooPortal2));
    assertEquals(2, provider1.managedResources.size());
    assertEquals(portal1, provider1.managedResources.get(0).resource);
    assertEquals(fooPortal1, provider1.managedResources.get(1).resource);
    assertEquals(2, provider2.managedResources.size());
    assertEquals(portal2, provider2.managedResources.get(0).resource);
    assertEquals(fooPortal2, provider2.managedResources.get(1).resource);
}
Also used : ContainerBuilder(org.exoplatform.container.ContainerBuilder) RootContainer(org.exoplatform.container.RootContainer) URL(java.net.URL) PortalContainer(org.exoplatform.container.PortalContainer)

Example 22 with PortalContainer

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

the class TestContainer method testPriorityPlugins.

public void testPriorityPlugins() {
    RootContainer rootContainer = RootContainer.getInstance();
    PortalContainer pcontainer = rootContainer.getPortalContainer("portal");
    assertNotNull(pcontainer);
    PriorityService ps = (PriorityService) pcontainer.getComponentInstanceOfType(PriorityService.class);
    assertNotNull(ps);
    List<ComponentPlugin> l = ps.getPlugins();
    assertNotNull(l);
    assertEquals(3, l.size());
    assertEquals("PluginPriority3", l.get(0).getName());
    assertEquals("PluginPriority1", l.get(1).getName());
    assertEquals("PluginPriority2", l.get(2).getName());
}
Also used : ComponentPlugin(org.exoplatform.container.component.ComponentPlugin) PriorityService(org.exoplatform.mocks.PriorityService) RootContainer(org.exoplatform.container.RootContainer) PortalContainer(org.exoplatform.container.PortalContainer)

Example 23 with PortalContainer

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

the class TestContainer method testComponent3.

public void testComponent3() throws Exception {
    RootContainer rootContainer = RootContainer.getInstance();
    PortalContainer pcontainer = rootContainer.getPortalContainer("portal");
    assertNotNull(pcontainer);
    DefaultComponent c = (DefaultComponent) pcontainer.getComponentInstanceOfType(DefaultComponent.class);
    assertNotNull(c);
    c = (DefaultComponent) pcontainer.getComponentInstanceOfType(DefaultComponent.class);
    assertNotNull(c);
    c = (DefaultComponent) pcontainer.getComponentInstanceOfType(DefaultComponent.class);
    assertNotNull(c);
}
Also used : RootContainer(org.exoplatform.container.RootContainer) PortalContainer(org.exoplatform.container.PortalContainer)

Example 24 with PortalContainer

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

the class TestWeldContainer method testIntegration.

public void testIntegration() {
    URL rootURL = getClass().getResource("test-exo-container.xml");
    URL portalURL = getClass().getResource("test-exo-container2.xml");
    assertNotNull(rootURL);
    assertNotNull(portalURL);
    // 
    new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).build();
    RootContainer root = RootContainer.getInstance();
    testIntegration(root);
    ComponentAdapter<H> adapterH = root.getComponentAdapterOfType(H.class);
    assertNull(adapterH);
    PortalContainer portal = PortalContainer.getInstance();
    adapterH = portal.getComponentAdapterOfType(H.class);
    assertNotNull(adapterH);
    H h = root.getComponentInstanceOfType(H.class);
    assertNull(h);
    h = portal.getComponentInstanceOfType(H.class);
    assertNotNull(h);
    assertSame(h, portal.getComponentInstanceOfType(H.class));
    assertSame(h, adapterH.getComponentInstance());
    List<ComponentAdapter<H>> adapters = root.getComponentAdaptersOfType(H.class);
    assertTrue(adapters == null || adapters.isEmpty());
    adapters = portal.getComponentAdaptersOfType(H.class);
    assertNotNull(adapters);
    assertEquals(1, adapters.size());
    assertSame(h, adapters.get(0).getComponentInstance());
    List<H> allH = root.getComponentInstancesOfType(H.class);
    assertTrue(allH == null || allH.isEmpty());
    allH = portal.getComponentInstancesOfType(H.class);
    assertNotNull(allH);
    assertEquals(1, allH.size());
    assertSame(h, allH.get(0));
}
Also used : ContainerBuilder(org.exoplatform.container.ContainerBuilder) RootContainer(org.exoplatform.container.RootContainer) URL(java.net.URL) ComponentAdapter(org.exoplatform.container.spi.ComponentAdapter) 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