From: Robert Varga Date: Sat, 7 Jun 2014 07:53:51 +0000 (+0200) Subject: BUG-1166: do not import BundleContext X-Git-Tag: release/helium~684 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=bc96b23c90955cca6ad6e9a5b504d51507abec45 BUG-1166: do not import BundleContext As it turns out, the entire import is only needed to get the canonical class name. Replace the import with a static string, leaving the dependency behind. Change-Id: Ia300738b2d2351404eae1b2da20a0c6bc41ecd22 Signed-off-by: Robert Varga --- 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 48a6c15706..8c65eaad14 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 @@ -31,9 +31,9 @@ import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.Generated import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.JavaFileInputBuilder; import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.TypeName; import org.opendaylight.yangtools.yang.common.QName; -import org.osgi.framework.BundleContext; public class AbsFactoryGeneratedObjectFactory { + private static final String BUNDLE_CONTEXT = "org.osgi.framework.BundleContext"; public GeneratedObject toGeneratedObject(ModuleMXBeanEntry mbe, Optional copyright) { FullyQualifiedName absFactoryFQN = new FullyQualifiedName(mbe.getPackageName(), mbe.getAbstractFactoryName()); @@ -91,7 +91,7 @@ public class AbsFactoryGeneratedObjectFactory { "public %s createModule(String instanceName, %s dependencyResolver, %s bundleContext) {\n"+ "return instantiateModule(instanceName, dependencyResolver, bundleContext);\n"+ "}\n", - Module.class.getCanonicalName(), DependencyResolver.class.getCanonicalName(), BundleContext.class.getCanonicalName())); + Module.class.getCanonicalName(), DependencyResolver.class.getCanonicalName(), BUNDLE_CONTEXT)); b.addToBody(getCreateModule(moduleFQN, moduleFields)); @@ -100,12 +100,12 @@ public class AbsFactoryGeneratedObjectFactory { "return new %s(new %s(NAME, instanceName), dependencyResolver, oldModule, oldInstance);\n"+ "}\n", moduleFQN, DependencyResolver.class.getCanonicalName(), moduleFQN, AutoCloseable.class.getCanonicalName(), - BundleContext.class.getCanonicalName(), moduleFQN, ModuleIdentifier.class.getCanonicalName())); + BUNDLE_CONTEXT, moduleFQN, ModuleIdentifier.class.getCanonicalName())); b.addToBody(format("\n"+ "public %s instantiateModule(String instanceName, %s dependencyResolver, %s bundleContext) {\n"+ "return new %s(new %s(NAME, instanceName), dependencyResolver);\n"+ - "}\n", moduleFQN, DependencyResolver.class.getCanonicalName(), BundleContext.class.getCanonicalName(), + "}\n", moduleFQN, DependencyResolver.class.getCanonicalName(), BUNDLE_CONTEXT, moduleFQN, ModuleIdentifier.class.getCanonicalName() )); @@ -118,7 +118,7 @@ public class AbsFactoryGeneratedObjectFactory { "@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, BundleContext.class.getCanonicalName(), moduleFQN)); + "}\n", moduleFQN, BUNDLE_CONTEXT, moduleFQN)); return new GeneratedObjectBuilder(b.build()).toGeneratedObject(); } @@ -127,8 +127,8 @@ public class AbsFactoryGeneratedObjectFactory { String result = "\n"+ "@Override\n"+ format("public %s createModule(String instanceName, %s dependencyResolver, %s old, %s bundleContext) throws Exception {\n", - Module.class.getCanonicalName(),DependencyResolver.class.getCanonicalName(), - DynamicMBeanWithInstance.class.getCanonicalName(),BundleContext.class.getCanonicalName())+ + Module.class.getCanonicalName(), DependencyResolver.class.getCanonicalName(), + DynamicMBeanWithInstance.class.getCanonicalName(), BUNDLE_CONTEXT)+ format("%s oldModule = null;\n",moduleFQN)+ "try {\n"+ format("oldModule = (%s) old.getModule();\n",moduleFQN)+