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;
}
public <T> T newMXBeanProxy(ObjectName on, Class<T> 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> T newMBeanProxy(ObjectName on, Class<T> clazz) {
return JMX.newMBeanProxy(configMBeanServer, on, clazz);
}
}
@Override
+ @Deprecated
+ /**
+ * {@inheritDoc}
+ */
public void destroyConfigBean(String moduleName, String instanceName)
throws InstanceNotFoundException {
destroyModule(ObjectNameUtil.createTransactionModuleON(
getTransactionName(), moduleName, instanceName));
}
+ @Override
+ public void destroyModule(String moduleName, String instanceName)
+ throws InstanceNotFoundException {
+ destroyModule(ObjectNameUtil.createTransactionModuleON(
+ getTransactionName(), moduleName, instanceName));
+ }
+
@Override
public void abortConfig() {
configTransactionControllerMXBeanProxy.abortConfig();
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();
}
}