Fixed AbstractMockedModule and BaseJMXRegistrator in config-manager 25/2125/5
authorMaros Marsalek <mmarsale@cisco.com>
Thu, 24 Oct 2013 08:37:50 +0000 (10:37 +0200)
committerMaros Marsalek <mmarsale@cisco.com>
Fri, 25 Oct 2013 07:52:10 +0000 (09:52 +0200)
Change-Id: I75cd8a3beabc65ffaec7159ed794a26bccce0148
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/BaseJMXRegistrator.java
opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractMockedModule.java

index be64238aaff17bf2cfeef85ca145aa9d61f79a85..09bc1f818fc563ae11e432cec37e148459a2e7dd 100644 (file)
@@ -7,13 +7,12 @@
  */
 package org.opendaylight.controller.config.manager.impl.jmx;
 
  */
 package org.opendaylight.controller.config.manager.impl.jmx;
 
-import java.util.Set;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
 
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.management.QueryExp;
 
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.management.QueryExp;
-
-import org.opendaylight.controller.config.api.ModuleIdentifier;
+import java.util.Set;
 
 public class BaseJMXRegistrator implements AutoCloseable {
 
 
 public class BaseJMXRegistrator implements AutoCloseable {
 
@@ -39,7 +38,7 @@ public class BaseJMXRegistrator implements AutoCloseable {
 
     public RootRuntimeBeanRegistratorImpl createRuntimeBeanRegistrator(
             ModuleIdentifier moduleIdentifier) {
 
     public RootRuntimeBeanRegistratorImpl createRuntimeBeanRegistrator(
             ModuleIdentifier moduleIdentifier) {
-        return new RootRuntimeBeanRegistratorImpl(internalJMXRegistrator,
+        return new RootRuntimeBeanRegistratorImpl(internalJMXRegistrator.createChild(),
                 moduleIdentifier);
     }
 
                 moduleIdentifier);
     }
 
index 87d6e8b698e6d44795e0850380a15f4924bbf72e..837ae2b3c86d7ee977648407b142f50dec17c76e 100644 (file)
@@ -14,15 +14,21 @@ import org.opendaylight.controller.config.spi.Module;
 public abstract class AbstractMockedModule implements Module {
 
     protected final AutoCloseable instance;
 public abstract class AbstractMockedModule implements Module {
 
     protected final AutoCloseable instance;
-
-    public AbstractMockedModule() throws Exception {
-        instance = prepareMockedInstance();
-    }
+    private final ModuleIdentifier id;
 
     protected abstract AutoCloseable prepareMockedInstance() throws Exception;
 
 
     protected abstract AutoCloseable prepareMockedInstance() throws Exception;
 
-    public AbstractMockedModule(DynamicMBeanWithInstance old) {
-        instance = old.getInstance();
+    public AbstractMockedModule(DynamicMBeanWithInstance old, ModuleIdentifier id) {
+        if(old!=null)
+            instance = old.getInstance();
+        else
+            try {
+                instance = prepareMockedInstance();
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+
+        this.id = id==null ? new ModuleIdentifier(getClass().getCanonicalName(), "mock") : id;
     }
 
     @Override
     }
 
     @Override
@@ -34,5 +40,9 @@ public abstract class AbstractMockedModule implements Module {
         return instance;
     }
 
         return instance;
     }
 
+    @Override
+    public ModuleIdentifier getIdentifier() {
+        return id;
+    }
 
 }
 
 }