Search in sources :

Example 16 with JmxTestBean

use of org.springframework.jmx.JmxTestBean in project spring-framework by spring-projects.

the class MBeanExporterTests method getBeanMap.

private Map<String, Object> getBeanMap() {
    Map<String, Object> map = new HashMap<>();
    map.put(OBJECT_NAME, new JmxTestBean());
    return map;
}
Also used : HashMap(java.util.HashMap) JmxTestBean(org.springframework.jmx.JmxTestBean) IJmxTestBean(org.springframework.jmx.IJmxTestBean)

Example 17 with JmxTestBean

use of org.springframework.jmx.JmxTestBean in project spring-framework by spring-projects.

the class MBeanExporterOperationsTests method testRegisterManagedResourceWithGeneratedObjectName.

@Test
void testRegisterManagedResourceWithGeneratedObjectName() throws Exception {
    final ObjectName objectNameTemplate = ObjectNameManager.getInstance("spring:type=Test");
    MBeanExporter exporter = new MBeanExporter();
    exporter.setServer(getServer());
    exporter.setNamingStrategy((managedBean, beanKey) -> objectNameTemplate);
    JmxTestBean bean1 = new JmxTestBean();
    JmxTestBean bean2 = new JmxTestBean();
    ObjectName reg1 = exporter.registerManagedResource(bean1);
    ObjectName reg2 = exporter.registerManagedResource(bean2);
    assertIsRegistered("Bean 1 not registered with MBeanServer", reg1);
    assertIsRegistered("Bean 2 not registered with MBeanServer", reg2);
    assertObjectNameMatchesTemplate(objectNameTemplate, reg1);
    assertObjectNameMatchesTemplate(objectNameTemplate, reg2);
}
Also used : JmxTestBean(org.springframework.jmx.JmxTestBean) ObjectName(javax.management.ObjectName) Test(org.junit.jupiter.api.Test)

Example 18 with JmxTestBean

use of org.springframework.jmx.JmxTestBean in project spring-framework by spring-projects.

the class MBeanClientInterceptorTests method onSetUp.

@Override
public void onSetUp() throws Exception {
    target = new JmxTestBean();
    target.setAge(100);
    target.setName("Rob Harrop");
    MBeanExporter adapter = new MBeanExporter();
    Map<String, Object> beans = new HashMap<>();
    beans.put(OBJECT_NAME, target);
    adapter.setServer(getServer());
    adapter.setBeans(beans);
    adapter.setAssembler(new ProxyTestAssembler());
    start(adapter);
}
Also used : HashMap(java.util.HashMap) MBeanExporter(org.springframework.jmx.export.MBeanExporter) JmxTestBean(org.springframework.jmx.JmxTestBean) IJmxTestBean(org.springframework.jmx.IJmxTestBean)

Aggregations

JmxTestBean (org.springframework.jmx.JmxTestBean)18 ObjectName (javax.management.ObjectName)12 HashMap (java.util.HashMap)11 Test (org.junit.Test)9 Attribute (javax.management.Attribute)8 Test (org.junit.jupiter.api.Test)7 IJmxTestBean (org.springframework.jmx.IJmxTestBean)6 Map (java.util.Map)2 StandardMBean (javax.management.StandardMBean)2 NotificationListenerRegistrar (org.springframework.jmx.access.NotificationListenerRegistrar)2 AttributeChangeNotification (javax.management.AttributeChangeNotification)1 Notification (javax.management.Notification)1 NotificationFilter (javax.management.NotificationFilter)1 ProxyFactory (org.springframework.aop.framework.ProxyFactory)1 NopInterceptor (org.springframework.aop.testfixture.interceptor.NopInterceptor)1 MBeanExporter (org.springframework.jmx.export.MBeanExporter)1