类javax.management.timer.TimerMBean源码实例Demo

下面列出了怎么用javax.management.timer.TimerMBean的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: quarks   文件: JMXControlServiceTest.java
@Test(expected=RuntimeException.class)
public void testDoubleRegister() throws Exception {
    
    ControlService cs = new JMXControlService(DOMAIN, new Hashtable<>());
    
    String type = "timer";
    String id = "a";
    String alias = "ControlA";
    String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
    try {
        cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
    } finally {
        cs.unregister(controlId);
    }
}
 
源代码2 项目: quarks   文件: JMXControlServiceTest.java
@Test(expected=RuntimeException.class)
public void testDoubleunregister() throws Exception {
    
    ControlService cs = new JMXControlService(DOMAIN, new Hashtable<>());
    
    String type = "timer";
    String id = "a";
    String alias = "ControlA";
    String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
    cs.unregister(controlId);
    cs.unregister(controlId);
}
 
源代码3 项目: quarks   文件: JMXControlServiceTest.java
@Test
public void testControlObject() throws Exception {
    
    ControlService cs = new JMXControlService(DOMAIN, new Hashtable<>());
    
    String type = "timer";
    String id = "a";
    String alias = "ControlA";
    String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
    
    assertNotNull(controlId);
    
    ObjectName on = ObjectName.getInstance(controlId);
    
    assertEquals(DOMAIN, on.getDomain());
    
    assertEquals(type, ObjectName.unquote(on.getKeyProperty("type")));
    assertEquals(id, ObjectName.unquote(on.getKeyProperty("id")));
    assertEquals(alias, ObjectName.unquote(on.getKeyProperty("alias")));
    assertEquals(TimerMBean.class.getName(), ObjectName.unquote(on.getKeyProperty("interface")));
    
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    
    assertTrue(mbs.isRegistered(on));
    
    cs.unregister(controlId);
    assertFalse(mbs.isRegistered(on));  
}
 
源代码4 项目: quarks   文件: JMXControlServiceTest.java
@Test
public void testAdditionalKeys() throws Exception {
    
    Hashtable<String,String> addKeys = new Hashtable<>();
    addKeys.put("job", "jobid");
    addKeys.put("device", ObjectName.quote("pi"));
    
    ControlService cs = new JMXControlService(DOMAIN, addKeys);
    
    String type = "timer";
    String id = "a";
    String alias = "ControlA";
    String controlId = cs.registerControl(type, id, alias, TimerMBean.class, new Timer());
    
    assertNotNull(controlId);
    
    ObjectName on = ObjectName.getInstance(controlId);
    
    assertEquals(DOMAIN, on.getDomain());
    
    assertEquals(type, ObjectName.unquote(on.getKeyProperty("type")));
    assertEquals(id, ObjectName.unquote(on.getKeyProperty("id")));
    assertEquals(alias, ObjectName.unquote(on.getKeyProperty("alias")));
    assertEquals(TimerMBean.class.getName(), ObjectName.unquote(on.getKeyProperty("interface")));
    
    assertEquals("jobid", on.getKeyProperty("job"));
    assertEquals("pi", ObjectName.unquote(on.getKeyProperty("device")));
 
    
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    
    assertTrue(mbs.isRegistered(on));
    
    cs.unregister(controlId);
    assertFalse(mbs.isRegistered(on));  
}
 
 类所在包
 同包方法