Search in sources :

Example 11 with RootContainer

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

the class TestRootContainerManagedIntegration method _testExplicitObjectName.

public void _testExplicitObjectName() throws Exception {
    RootContainer container = createRootContainer("configuration1.xml");
    Object expectedObject = container.getComponentInstance("ManagedWithExplicitObjectName");
    assertNotNull(expectedObject);
    MBeanServer server = container.getMBeanServer();
    assertNotNull(server);
    Object object = server.getAttribute(ObjectName.getInstance("exo:object=ManagedWithExplicitObjectName"), "Reference");
    assertNotNull(object);
    assertEquals(expectedObject, object);
}
Also used : RootContainer(org.exoplatform.container.RootContainer) MBeanServer(javax.management.MBeanServer)

Example 12 with RootContainer

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

the class TestRootContainerManagedIntegration method testObjectNameTemplate.

public void testObjectNameTemplate() throws Exception {
    RootContainer container = createRootContainer("configuration2.xml");
    Object expectedFoo = container.getComponentInstance("Foo");
    Object expectedBar = container.getComponentInstance("Bar");
    assertNotNull(expectedFoo);
    assertNotNull(expectedBar);
    MBeanServer server = container.getMBeanServer();
    assertNotNull(server);
    Object foo = server.getAttribute(ObjectName.getInstance("exo:object=Foo"), "Reference");
    assertNotNull(foo);
    Object bar = server.getAttribute(ObjectName.getInstance("exo:object=Bar"), "Reference");
    assertNotNull(bar);
    assertEquals(expectedFoo, foo);
    assertEquals(expectedBar, bar);
}
Also used : RootContainer(org.exoplatform.container.RootContainer) MBeanServer(javax.management.MBeanServer)

Example 13 with RootContainer

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

the class TestRootContainerManagedIntegration method _testObjectNameTemplateOverriddenByExplicitObjectName.

public void _testObjectNameTemplateOverriddenByExplicitObjectName() throws Exception {
    RootContainer container = createRootContainer("configuration3.xml");
    Object expectedObject = container.getComponentInstance("ManagedWithObjectNameTemplateOverriddenByExplicitObjectName");
    assertNotNull(expectedObject);
    MBeanServer server = container.getMBeanServer();
    assertNotNull(server);
    Object object = server.getAttribute(ObjectName.getInstance("exo:object=ManagedWithObjectNameTemplateOverriddenByExplicitObjectName"), "Reference");
    assertNotNull(object);
    assertEquals(expectedObject, object);
}
Also used : RootContainer(org.exoplatform.container.RootContainer) MBeanServer(javax.management.MBeanServer)

Example 14 with RootContainer

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

the class TestRootContainerManagedIntegration method testRootManagedRequestLifeCycle.

public void testRootManagedRequestLifeCycle() throws Exception {
    RootContainer container = createRootContainer("configuration5.xml");
    ManagedComponentRequestLifeCycle component = (ManagedComponentRequestLifeCycle) container.getComponentInstanceOfType(ManagedComponentRequestLifeCycle.class);
    assertNotNull(component);
    MBeanServer server = container.getMBeanServer();
    server.invoke(new ObjectName("exo:object=ManagedComponentRequestLifeCycle"), "foo", new Object[0], new String[0]);
    assertEquals(1, component.startCount);
    assertEquals(1, component.fooCount);
    assertEquals(1, component.endCount);
    assertSame(container, component.startContainer);
    assertSame(container, component.endContainer);
}
Also used : ManagedComponentRequestLifeCycle(org.exoplatform.container.jmx.support.ManagedComponentRequestLifeCycle) RootContainer(org.exoplatform.container.RootContainer) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 15 with RootContainer

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

the class TestRootContainerManagedIntegration method testManagementAwareManagingOtherBeans.

public void testManagementAwareManagingOtherBeans() throws Exception {
    RootContainer container = createRootContainer("configuration4.xml");
    ManagedManagementAware aware = (ManagedManagementAware) container.getComponentInstance("ManagedManagementAware");
    aware.context.register(new ManagedWithObjectNameTemplate("juu"));
    container.getMBeanServer().getObjectInstance(new ObjectName("exo:object=juu"));
}
Also used : ManagedWithObjectNameTemplate(org.exoplatform.container.jmx.support.ManagedWithObjectNameTemplate) ManagedManagementAware(org.exoplatform.container.jmx.support.ManagedManagementAware) RootContainer(org.exoplatform.container.RootContainer) ObjectName(javax.management.ObjectName)

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