Add reverse() method in Edge and Path classes
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / testingservices / parallelapsp / TestingParallelAPSPModule.java
index de283fec034bc9e596a2a958b1249ad5fd7db52c..f4ba5ef887e359b9e5a6ab324ac58cc359ae565f 100644 (file)
@@ -17,6 +17,7 @@ import javax.annotation.concurrent.NotThreadSafe;
 import javax.management.ObjectName;
 
 import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.JmxAttribute;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.annotations.RequireInterface;
 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
@@ -39,26 +40,21 @@ public class TestingParallelAPSPModule implements Module,
     private final DependencyResolver dependencyResolver;
     private final AutoCloseable oldCloseable;
     private final TestingParallelAPSPImpl oldInstance;
-    private final ModuleIdentifier name;
+    private final ModuleIdentifier identifier;
     private ObjectName threadPoolON;
     private TestingParallelAPSPImpl instance;
     private String someParam;
 
-    public TestingParallelAPSPModule(ModuleIdentifier name,
+    public TestingParallelAPSPModule(ModuleIdentifier identifier,
             DependencyResolver dependencyResolver,
             @Nullable AutoCloseable oldCloseable,
             @Nullable TestingParallelAPSPImpl oldInstance) {
-        this.name = name;
+        this.identifier = identifier;
         this.dependencyResolver = dependencyResolver;
         this.oldCloseable = oldCloseable;
         this.oldInstance = oldInstance;
     }
 
-    @Override
-    public ModuleIdentifier getName() {
-        return name;
-    }
-
     @Override
     public ObjectName getThreadPool() {
         return threadPoolON;
@@ -87,19 +83,22 @@ public class TestingParallelAPSPModule implements Module,
         return instance.getMaxNumberOfThreads();
     }
 
+    // this would be generated:
+    private final JmxAttribute threadPoolONJMXAttribute = new JmxAttribute("threadPoolON");
+
     @Override
     public void validate() {
         checkNotNull(threadPoolON, "Parameter 'threadPool' must be set");
         dependencyResolver.validateDependency(
                 TestingThreadPoolServiceInterface.class, threadPoolON,
-                "threadPoolON");
+                threadPoolONJMXAttribute);
 
         checkState(Strings.isNullOrEmpty(someParam) == false,
                 "Parameter 'SomeParam' is blank");
         // check that calling resolveInstance fails
         try {
             dependencyResolver.resolveInstance(TestingThreadPoolIfc.class,
-                    threadPoolON);
+                    threadPoolON, threadPoolONJMXAttribute);
             throw new RuntimeException("fail");
         } catch (IllegalStateException e) {
             checkState("Commit was not triggered".equals(e.getMessage()),
@@ -111,12 +110,11 @@ public class TestingParallelAPSPModule implements Module,
     public Closeable getInstance() {
         if (instance == null) {
             TestingThreadPoolIfc threadPoolInstance = dependencyResolver
-                    .resolveInstance(TestingThreadPoolIfc.class, threadPoolON);
+                    .resolveInstance(TestingThreadPoolIfc.class, threadPoolON, threadPoolONJMXAttribute);
 
             if (oldInstance != null) {
                 // changing thread pool is not supported
-                boolean reuse = threadPoolInstance.equals(oldInstance
-                        .getThreadPool());
+                boolean reuse = threadPoolInstance == oldInstance.getThreadPool();
                 if (reuse) {
                     logger.debug("Reusing old instance");
                     instance = oldInstance;
@@ -138,4 +136,11 @@ public class TestingParallelAPSPModule implements Module,
         }
         return instance;
     }
+
+    @Override
+    public ModuleIdentifier getIdentifier() {
+        return identifier;
+    }
+
+
 }