List of usage examples for javax.management JMX newMXBeanProxy
public static <T> T newMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass)
From source file:org.opendaylight.controller.config.yang.logback.config.LogbackWithXmlConfigModuleTest.java
/** * Tests configuration of Logger factory. * * @throws MalformedObjectNameException//ww w .j av a 2 s .com */ @Test public void test() throws InstanceAlreadyExistsException, InstanceNotFoundException, MalformedObjectNameException, ValidationException, ConflictingVersionException { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); ObjectName nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), LogbackModuleFactory.INSTANCE_NAME); LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameRetrieved, LogbackModuleMXBean.class); assertEquals(1, bean.getConsoleAppenderTO().size()); assertEquals(1, bean.getRollingFileAppenderTO().size()); transaction.commit(); transaction = configRegistryClient.createTransaction(); nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), "singleton"); bean = JMX.newMXBeanProxy(platformMBeanServer, nameRetrieved, LogbackModuleMXBean.class); assertEquals(1, bean.getConsoleAppenderTO().size()); assertEquals(1, bean.getRollingFileAppenderTO().size()); }
From source file:org.opendaylight.controller.config.yang.logback.config.LogbackWithXmlConfigModuleTest.java
/** * Tests filtering loggers. Loggers inherited from ROOT logger and duplicate * loggers should be removed.//from www .ja v a 2 s. c o m */ @Test public void testAllLoggers() throws InstanceAlreadyExistsException, InstanceNotFoundException { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); LogbackModuleMXBean bean = JMX.newMXBeanProxy(ManagementFactory.getPlatformMBeanServer(), transaction.lookupConfigBean("logback", "singleton"), LogbackModuleMXBean.class); assertEquals(5, bean.getLoggerTO().size()); }
From source file:org.opendaylight.controller.config.yang.logback.config.LogbackWithXmlConfigModuleTest.java
/** * Add new logger using FileAppender//from ww w .j a va2 s .com * * @throws MalformedObjectNameException */ @Test public void testAddNewLogger() throws InstanceAlreadyExistsException, InstanceNotFoundException, MalformedObjectNameException, ValidationException, ConflictingVersionException { ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction(); ObjectName nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), LogbackModuleFactory.INSTANCE_NAME); LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameRetrieved, LogbackModuleMXBean.class); assertEquals(5, bean.getLoggerTO().size()); List<LoggerTO> loggers = Lists.newArrayList(bean.getLoggerTO()); LoggerTO logger = new LoggerTO(); logger.setAppenders(Lists.newArrayList("FILE")); logger.setLevel("INFO"); logger.setLoggerName("fileLogger"); loggers.add(logger); bean.setLoggerTO(loggers); transaction.commit(); transaction = configRegistryClient.createTransaction(); nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), "singleton"); bean = JMX.newMXBeanProxy(platformMBeanServer, nameRetrieved, LogbackModuleMXBean.class); assertEquals(6, bean.getLoggerTO().size()); }
From source file:org.opendaylight.infrautils.diagstatus.MBeanUtils.java
private static <T> T getMBean(String jmxName, Class<T> klass, MBeanServerConnection mbsc) throws MalformedObjectNameException { ObjectName objectName = new ObjectName(jmxName); if (JMX.isMXBeanInterface(klass)) { return JMX.newMXBeanProxy(mbsc, objectName, klass); } else {/*from w ww .ja va 2s . c om*/ return JMX.newMBeanProxy(mbsc, objectName, klass); } }