Search in sources :

Example 1 with ManagementContextImpl

use of org.exoplatform.container.management.ManagementContextImpl in project kernel by exoplatform.

the class TestPortalContainerManagedIntegration method testManagementContext.

public void testManagementContext() {
    URL rootURL = TestPortalContainerManagedIntegration.class.getResource("root-configuration.xml");
    URL portalURL = TestPortalContainerManagedIntegration.class.getResource("portal-configuration.xml");
    // 
    RootContainer root = new ContainerBuilder().withRoot(rootURL).withPortal(portalURL).build();
    ManagementContextImpl rootManagementContext = (ManagementContextImpl) root.getManagementContext();
    // 
    PortalContainer portal = PortalContainer.getInstance();
    ManagementContextImpl portalManagementContext = (ManagementContextImpl) portal.getManagementContext();
    assertSame(root.getManagementContext(), portalManagementContext.getParent());
    assertNotNull(portalManagementContext.findContainer());
    // 
    SimpleManagementAware rootManagementAware = (SimpleManagementAware) root.getComponentInstance("RootManagementAware");
    ManagementContextImpl rootManagementAwareContext = (ManagementContextImpl) rootManagementAware.context;
    assertSame(rootManagementContext, rootManagementAwareContext.getParent());
    // 
    SimpleManagementAware portalManagementAware = (SimpleManagementAware) portal.getComponentInstance("PortalManagementAware");
    ManagementContextImpl portalManagementAwareContext = (ManagementContextImpl) portalManagementAware.context;
    assertSame(portalManagementContext, portalManagementAwareContext.getParent());
}
Also used : ContainerBuilder(org.exoplatform.container.ContainerBuilder) RootContainer(org.exoplatform.container.RootContainer) ManagementContextImpl(org.exoplatform.container.management.ManagementContextImpl) SimpleManagementAware(org.exoplatform.container.jmx.support.SimpleManagementAware) URL(java.net.URL) PortalContainer(org.exoplatform.container.PortalContainer)

Aggregations

URL (java.net.URL)1 ContainerBuilder (org.exoplatform.container.ContainerBuilder)1 PortalContainer (org.exoplatform.container.PortalContainer)1 RootContainer (org.exoplatform.container.RootContainer)1 SimpleManagementAware (org.exoplatform.container.jmx.support.SimpleManagementAware)1 ManagementContextImpl (org.exoplatform.container.management.ManagementContextImpl)1