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=4cf766a8120ef4c559eb45a9883c7583c1983f8b;hp=3583dafd0d46c3fcedb070e00b8cc175255bc4c8;hb=f32ff81642b317eedcb973f7cdf0ffc9642bcf3e;hpb=0ae12c54560ef14cb8c08beef4553f7523d41578 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 3583dafd0d..4cf766a812 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,16 +9,14 @@ 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; import javax.management.JMException; import javax.management.JMX; +import javax.management.MBeanException; import javax.management.MBeanServer; import javax.management.ObjectName; -import javax.management.RuntimeMBeanException; - import org.opendaylight.controller.config.api.ConflictingVersionException; import org.opendaylight.controller.config.api.ValidationException; import org.opendaylight.controller.config.api.jmx.CommitStatus; @@ -45,9 +43,21 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient { } public T newMXBeanProxy(ObjectName on, Class clazz) { + // 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()); + // 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); } + /** + * Usage of this method indicates error as config JMX uses solely MXBeans. + * Use {@link #newMXBeanProxy(javax.management.ObjectName, Class)} + * or {@link JMX#newMBeanProxy(javax.management.MBeanServerConnection, javax.management.ObjectName, Class)} + * This method will be removed soon. + */ + @Deprecated public T newMBeanProxy(ObjectName on, Class clazz) { return JMX.newMBeanProxy(configMBeanServer, on, clazz); } @@ -234,10 +244,15 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient { throws ValidationException { try { configMBeanServer.invoke(configBeanON, "validate", null, null); + } catch (MBeanException e) { + Exception targetException = e.getTargetException(); + if (targetException instanceof ValidationException){ + throw (ValidationException) targetException; + } else { + throw new RuntimeException(e); + } } catch (JMException e) { throw new RuntimeException(e); - } catch (RuntimeMBeanException e) { - throw e.getTargetException(); } }