X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fyang-jmx-generator-plugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyangjmxgenerator%2Fplugin%2Fgofactory%2FAbsFactoryGeneratedObjectFactory.java;h=25314cb5f5fbe963488633bb50c6285ae58bd5a2;hp=8c65eaad14247a8be963c1dbc1d3095c7427d4d9;hb=dd65a7ecf4237d0e11e01f71d2184c2bc9de2895;hpb=83e1c610eeefba667a19c243fbc1098072a8079d diff --git a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsFactoryGeneratedObjectFactory.java b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsFactoryGeneratedObjectFactory.java index 8c65eaad14..25314cb5f5 100644 --- a/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsFactoryGeneratedObjectFactory.java +++ b/opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsFactoryGeneratedObjectFactory.java @@ -114,11 +114,12 @@ public class AbsFactoryGeneratedObjectFactory { "throw new UnsupportedOperationException(\"Class reloading is not supported\");\n"+ "}\n", moduleFQN, DynamicMBeanWithInstance.class.getCanonicalName())); + // TODO The generic specifier in HashSet<> isn't necessary, but the Eclipse AST parser used in the unit tests doesn't support this b.addToBody(format("\n"+ "@Override\n"+ "public java.util.Set<%s> getDefaultModules(org.opendaylight.controller.config.api.DependencyResolverFactory dependencyResolverFactory, %s bundleContext) {\n"+ - "return new java.util.HashSet<%s>();\n"+ - "}\n", moduleFQN, BUNDLE_CONTEXT, moduleFQN)); + "return new java.util.HashSet<%1$s>();\n"+ + "}\n", moduleFQN, BUNDLE_CONTEXT)); return new GeneratedObjectBuilder(b.build()).toGeneratedObject(); } @@ -129,7 +130,7 @@ public class AbsFactoryGeneratedObjectFactory { format("public %s createModule(String instanceName, %s dependencyResolver, %s old, %s bundleContext) throws Exception {\n", Module.class.getCanonicalName(), DependencyResolver.class.getCanonicalName(), DynamicMBeanWithInstance.class.getCanonicalName(), BUNDLE_CONTEXT)+ - format("%s oldModule = null;\n",moduleFQN)+ + format("%s oldModule;\n",moduleFQN)+ "try {\n"+ format("oldModule = (%s) old.getModule();\n",moduleFQN)+ "} catch(Exception e) {\n"+ @@ -150,14 +151,20 @@ public class AbsFactoryGeneratedObjectFactory { private static String getServiceIfcsInitialization(List providedServices) { String generic = format("Class", AbstractServiceInterface.class.getCanonicalName()); - String result = format("static {\n"+ - "java.util.Set<%1$s> serviceIfcs2 = new java.util.HashSet<%1$s>();\n", generic); + String result = "static {\n"; + if (!providedServices.isEmpty()) { + // TODO The generic specifier in HashSet<> isn't necessary, but the Eclipse AST parser used in the unit tests doesn't support this + result += format("java.util.Set<%1$s> serviceIfcs2 = new java.util.HashSet<%1$s>();\n", generic); - for(FullyQualifiedName fqn: providedServices) { - result += format("serviceIfcs2.add(%s.class);\n", fqn); + for(FullyQualifiedName fqn: providedServices) { + result += format("serviceIfcs2.add(%s.class);\n", fqn); + } + + result += "serviceIfcs = java.util.Collections.unmodifiableSet(serviceIfcs2);\n"; + } else { + result += "serviceIfcs = java.util.Collections.emptySet();\n"; } - result += "serviceIfcs = java.util.Collections.unmodifiableSet(serviceIfcs2);\n"+ - "}\n"; + result += "}\n"; // add isModuleImplementingServiceInterface and getImplementedServiceIntefaces methods