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=b37d9186d0654a892e80dc5dabca5f47b4a4d463;hp=8c65eaad14247a8be963c1dbc1d3095c7427d4d9;hb=7c912dbbd4fefc97229bd0bdbb9d46391507ec9c;hpb=48814d6a264b8f13e5db1422336d9ef25cb05fa9 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..b37d9186d0 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 @@ -110,15 +110,21 @@ 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())); + // 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,11 +135,11 @@ 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)+ + 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); @@ -150,14 +156,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