Search in sources :

Example 1 with ManagedManagementAware

use of org.exoplatform.container.jmx.support.ManagedManagementAware 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)

Example 2 with ManagedManagementAware

use of org.exoplatform.container.jmx.support.ManagedManagementAware in project kernel by exoplatform.

the class TestRootContainerManagedIntegration method testManagementAware.

public void testManagementAware() throws Exception {
    RootContainer container = createRootContainer("configuration4.xml");
    ManagedManagementAware aware = (ManagedManagementAware) container.getComponentInstance("ManagedManagementAware");
    assertNotNull(aware.context);
    MBeanServer server = container.getMBeanServer();
    assertNotNull(server);
    Object foo = server.getAttribute(ObjectName.getInstance("exo:object=Foo"), "Reference");
    assertNotNull(foo);
    assertEquals(aware.foo, foo);
    ManagedDependent expectedBar = new ManagedDependent("Bar");
    aware.context.register(expectedBar);
    assertEquals(1, server.queryMBeans(ObjectName.getInstance("exo:object=Bar"), null).size());
    Object bar = server.getAttribute(ObjectName.getInstance("exo:object=Bar"), "Reference");
    assertEquals(expectedBar, bar);
    aware.context.unregister(expectedBar);
    assertEquals(0, server.queryMBeans(ObjectName.getInstance("exo:object=Bar"), null).size());
}
Also used : ManagedManagementAware(org.exoplatform.container.jmx.support.ManagedManagementAware) RootContainer(org.exoplatform.container.RootContainer) ManagedDependent(org.exoplatform.container.jmx.support.ManagedDependent) MBeanServer(javax.management.MBeanServer)

Aggregations

RootContainer (org.exoplatform.container.RootContainer)2 ManagedManagementAware (org.exoplatform.container.jmx.support.ManagedManagementAware)2 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 ManagedDependent (org.exoplatform.container.jmx.support.ManagedDependent)1 ManagedWithObjectNameTemplate (org.exoplatform.container.jmx.support.ManagedWithObjectNameTemplate)1