Gen. Abstract*ModuleFactory handleChangedClass() with DependencyResolver 14/40514/5
authorMichael Vorburger <vorburger@redhat.com>
Sat, 18 Jun 2016 18:02:19 +0000 (20:02 +0200)
committerTom Pantelis <tpanteli@brocade.com>
Fri, 8 Jul 2016 04:09:57 +0000 (04:09 +0000)
Bug: 2855
Change-Id: Ieb010d67983a4807bd1e5b55886ba0c4c3f13385
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsFactoryGeneratedObjectFactory.java
opendaylight/config/yang-jmx-generator-plugin/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGeneratorTest.java

index 25314cb..b37d918 100644 (file)
@@ -110,6 +110,11 @@ public class AbsFactoryGeneratedObjectFactory {
         ));
 
         b.addToBody(format("\n"+
+                "public %s handleChangedClass(%s dependencyResolver, %s old, %s bundleContext) throws Exception {\n"+
+                    "return handleChangedClass(old);\n"+
+                "}\n", moduleFQN, DependencyResolver.class.getCanonicalName(), DynamicMBeanWithInstance.class.getCanonicalName(), BUNDLE_CONTEXT));
+
+        b.addToBody(format("\n@Deprecated\n"+
             "public %s handleChangedClass(%s old) throws Exception {\n"+
                 "throw new UnsupportedOperationException(\"Class reloading is not supported\");\n"+
             "}\n", moduleFQN, DynamicMBeanWithInstance.class.getCanonicalName()));
@@ -132,9 +137,9 @@ public class AbsFactoryGeneratedObjectFactory {
                                 DynamicMBeanWithInstance.class.getCanonicalName(), BUNDLE_CONTEXT)+
                 format("%s oldModule;\n",moduleFQN)+
                 "try {\n"+
-                    format("oldModule = (%s) old.getModule();\n",moduleFQN)+
+                    format("oldModule = (%s) old.getModule();\n", moduleFQN)+
                 "} catch(Exception e) {\n"+
-                    "return handleChangedClass(old);\n"+
+                    "return handleChangedClass(dependencyResolver, old, bundleContext);\n"+
                 "}\n"+
             format("%s module = instantiateModule(instanceName, dependencyResolver, oldModule, old.getInstance(), bundleContext);\n", moduleFQN);
 
index 2fe0871..583d297 100644 (file)
@@ -20,7 +20,6 @@ import static org.opendaylight.controller.config.yangjmxgenerator.PackageTransla
 import com.github.javaparser.JavaParser;
 import com.github.javaparser.ParseException;
 import com.github.javaparser.ast.CompilationUnit;
-import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.io.Files;
@@ -262,12 +261,7 @@ public class JMXGeneratorTest extends AbstractGeneratorTest {
             }
         }
 
-        verifyXmlFiles(Collections2.filter(files, new Predicate<File>() {
-            @Override
-            public boolean apply(final File input) {
-                return input.getName().endsWith("xml");
-            }
-        }));
+        verifyXmlFiles(Collections2.filter(files, input -> input.getName().endsWith("xml")));
 
         // verify ModuleFactory file
         File moduleFactoryFile = JMXGenerator.concatFolders(generatedResourcesDir, "META-INF", "services",
@@ -324,7 +318,7 @@ public class JMXGeneratorTest extends AbstractGeneratorTest {
         visitor.assertField(
                 "private static final java.util.Set<Class<? extends org.opendaylight.controller.config.api.annotations.AbstractServiceInterface>> serviceIfcs");
 
-        assertFactoryMethods(visitor.methods, 9);
+        assertFactoryMethods(visitor.methods, 10);
         visitor.assertMethodDescriptions(0);
         visitor.assertMethodJavadocs(0);
     }
@@ -371,7 +365,7 @@ public class JMXGeneratorTest extends AbstractGeneratorTest {
         args.add(new ArgumentAssertion("Class<? extends org.opendaylight.controller.config.api.annotations.AbstractServiceInterface>", "serviceInterface"));
         assertMethodPresent(methods, new MethodAssertion("boolean", "isModuleImplementingServiceInterface", args));
 
-        assertEquals(methods.size(), expectedSize);
+        assertEquals(expectedSize, methods.size());
     }
 
     private static void assertMethodPresent(final Set<String> methods, final MethodAssertion methodAssertion) {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.