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=20e26f6508513a70c60694586e8351e9e84709bc;hp=4cf766a8120ef4c559eb45a9883c7583c1983f8b;hb=73e969cf365dd78772596c71e940ae44fe2f22d3;hpb=00a8425f94b376e11050175b2c541c31e6b0e2cc 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..20e26f6508 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 @@ -9,6 +9,7 @@ package org.opendaylight.controller.config.util; import java.util.Map; import java.util.Set; + import javax.management.Attribute; import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; @@ -17,6 +18,7 @@ import javax.management.JMX; import javax.management.MBeanException; import javax.management.MBeanServer; import javax.management.ObjectName; + import org.opendaylight.controller.config.api.ConflictingVersionException; import org.opendaylight.controller.config.api.ValidationException; import org.opendaylight.controller.config.api.jmx.CommitStatus; @@ -43,12 +45,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); } /** @@ -258,9 +261,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); @@ -270,6 +274,21 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient { } } + @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 Set getAvailableModuleFactoryQNames() { return configTransactionControllerMXBeanProxy.getAvailableModuleFactoryQNames();