X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Futil%2FConfigTransactionJMXClient.java;h=d49c37ddd80914248c7894c58e7bdc5895c28aec;hb=f336ffef3aaf674ba23133cb5c5201105e5d8637;hp=bc188515538485f9a13f87366a281a893a5984ae;hpb=75f9ebff528344841c86e08d302340638db20858;p=controller.git 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 bc18851553..d49c37ddd8 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,7 +9,6 @@ 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; @@ -18,7 +17,6 @@ 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; @@ -45,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); } /** @@ -89,6 +88,11 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient { return configTransactionControllerMXBeanProxy.createModule(moduleName, instanceName); } + @Override + public void reCreateModule(ObjectName objectName) throws InstanceNotFoundException { + configTransactionControllerMXBeanProxy.reCreateModule(objectName); + } + @Override public void destroyModule(ObjectName objectName) throws InstanceNotFoundException { @@ -241,6 +245,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 { @@ -260,9 +284,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); @@ -273,21 +298,17 @@ 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"); + public Set getAvailableModuleFactoryQNames() { + return configTransactionControllerMXBeanProxy.getAvailableModuleFactoryQNames(); + } - 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 lookupRuntimeBeans() { + return configTransactionControllerMXBeanProxy.lookupRuntimeBeans(); } @Override - public Set getAvailableModuleFactoryQNames() { - return configTransactionControllerMXBeanProxy.getAvailableModuleFactoryQNames(); + public Set lookupRuntimeBeans(final String moduleName, final String instanceName) { + return configTransactionControllerMXBeanProxy.lookupRuntimeBeans(moduleName, instanceName); } }