X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Futil%2FConfigTransactionJMXClient.java;h=26ca1391ad4bf32eea9708e2db47f21cc33bdcfa;hp=4cf766a8120ef4c559eb45a9883c7583c1983f8b;hb=5c008222efa5c0af49cf8a52881a6299b1e249dc;hpb=0d78fea60c4818145e7bd8479427dfc04f0f8145 diff --git a/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/ConfigTransactionJMXClient.java b/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/ConfigTransactionJMXClient.java index 4cf766a812..26ca1391ad 100644 --- a/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/ConfigTransactionJMXClient.java +++ b/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/ConfigTransactionJMXClient.java @@ -43,12 +43,13 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient { } public T newMXBeanProxy(ObjectName on, Class clazz) { + ObjectName onName = on; // if on is without transaction, add it. Reason is that when using getters on MXBeans the transaction name is stripped - on = ObjectNameUtil.withTransactionName(on, getTransactionName()); + onName = ObjectNameUtil.withTransactionName(onName, getTransactionName()); // if this is service reference and user requests for implementation, look it up - on = ConfigRegistryJMXClient.translateServiceRefIfPossible(on, clazz, configMBeanServer); - on = ObjectNameUtil.withTransactionName(on, getTransactionName()); - return JMX.newMXBeanProxy(configMBeanServer, on, clazz); + onName = ConfigRegistryJMXClient.translateServiceRefIfPossible(onName, clazz, configMBeanServer); + onName = ObjectNameUtil.withTransactionName(onName, getTransactionName()); + return JMX.newMXBeanProxy(configMBeanServer, onName, clazz); } /** @@ -239,6 +240,26 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient { configTransactionControllerMXBeanProxy.checkServiceReferenceExists(objectName); } + @Override + public Attribute getAttribute(ObjectName on, String attrName) { + if (ObjectNameUtil.getTransactionName(on) == null) { + throw new IllegalArgumentException("Not in transaction instance " + + on + ", no transaction name present"); + } + + try { + return new Attribute(attrName, configMBeanServer.getAttribute(on,attrName)); + } catch (JMException e) { + throw new IllegalStateException("Unable to get attribute " + + attrName + " for " + on, e); + } + } + + @Override + public Object getAttributeCurrentValue(ObjectName on, String attrName) { + return getAttribute(on, attrName).getValue(); + } + @Override public void validateBean(ObjectName configBeanON) throws ValidationException { @@ -258,9 +279,10 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient { @Override public void setAttribute(ObjectName on, String attrName, Attribute attribute) { - if (ObjectNameUtil.getTransactionName(on) == null) + if (ObjectNameUtil.getTransactionName(on) == null) { throw new IllegalArgumentException("Not in transaction instance " + on + ", no transaction name present"); + } try { configMBeanServer.setAttribute(on, attribute); @@ -274,4 +296,14 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient { public Set getAvailableModuleFactoryQNames() { return configTransactionControllerMXBeanProxy.getAvailableModuleFactoryQNames(); } + + @Override + public Set lookupRuntimeBeans() { + return configTransactionControllerMXBeanProxy.lookupRuntimeBeans(); + } + + @Override + public Set lookupRuntimeBeans(final String moduleName, final String instanceName) { + return configTransactionControllerMXBeanProxy.lookupRuntimeBeans(moduleName, instanceName); + } }