Search in sources :

Example 36 with RootContainer

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

the class TestContainer method testComponent.

public void testComponent() throws Exception {
    RootContainer rootContainer = RootContainer.getInstance();
    MockService mservice = (MockService) rootContainer.getComponentInstance("MockService");
    assertTrue(mservice != null);
    assertTrue(mservice.getPlugins().size() == 2);
}
Also used : MockService(org.exoplatform.mocks.MockService) RootContainer(org.exoplatform.container.RootContainer)

Example 37 with RootContainer

use of org.exoplatform.container.RootContainer 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 38 with RootContainer

use of org.exoplatform.container.RootContainer 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

RootContainer (org.exoplatform.container.RootContainer)38 URL (java.net.URL)14 ContainerBuilder (org.exoplatform.container.ContainerBuilder)14 PortalContainer (org.exoplatform.container.PortalContainer)9 MBeanServer (javax.management.MBeanServer)8 ExoContainer (org.exoplatform.container.ExoContainer)4 ObjectName (javax.management.ObjectName)3 ObjectInstance (javax.management.ObjectInstance)2 ManagedManagementAware (org.exoplatform.container.jmx.support.ManagedManagementAware)2 ManagedWithObjectNameTemplate (org.exoplatform.container.jmx.support.ManagedWithObjectNameTemplate)2 ComponentAdapter (org.exoplatform.container.spi.ComponentAdapter)2 InitParams (org.exoplatform.container.xml.InitParams)2 ObjectParameter (org.exoplatform.container.xml.ObjectParameter)2 Set (java.util.Set)1 ComponentPlugin (org.exoplatform.container.component.ComponentPlugin)1 ComponentRequestLifecycle (org.exoplatform.container.component.ComponentRequestLifecycle)1 ExoContainerFinder (org.exoplatform.container.jmx.support.ExoContainerFinder)1 ManagedByManager (org.exoplatform.container.jmx.support.ManagedByManager)1 ManagedComponentRequestLifeCycle (org.exoplatform.container.jmx.support.ManagedComponentRequestLifeCycle)1 ManagedDependent (org.exoplatform.container.jmx.support.ManagedDependent)1