X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2Fosgi%2FModuleFactoryBundleTracker.java;h=cd72a73ecf3455365c35ae1a74b71d62654f9763;hb=412db94945c5db5d2da918f5e23bd3abcecc4d10;hp=3c8fc042a37c5ebe048b8b1e47a1016674b6402c;hpb=8161319be53a57e3ac22ba72f267483526e11e0d;p=controller.git diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTracker.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTracker.java index 3c8fc042a3..cd72a73ecf 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTracker.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTracker.java @@ -8,13 +8,11 @@ package org.opendaylight.controller.config.manager.impl.osgi; import static java.lang.String.format; - import com.google.common.annotations.VisibleForTesting; -import java.io.InputStream; +import com.google.common.base.Charsets; +import com.google.common.io.Resources; +import java.io.IOException; import java.net.URL; -import java.util.List; - -import org.apache.commons.io.IOUtils; import org.opendaylight.controller.config.spi.ModuleFactory; import org.osgi.framework.Bundle; import org.osgi.framework.BundleEvent; @@ -23,7 +21,6 @@ import org.osgi.util.tracker.BundleTrackerCustomizer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * OSGi extender that listens for bundle activation events. Reads file * META-INF/services/org.opendaylight.controller.config.spi.ModuleFactory, each @@ -35,7 +32,7 @@ import org.slf4j.LoggerFactory; */ public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer { private final BlankTransactionServiceTracker blankTransactionServiceTracker; - private static final Logger LOGGER = LoggerFactory.getLogger(ModuleFactoryBundleTracker.class); + private static final Logger LOG = LoggerFactory.getLogger(ModuleFactoryBundleTracker.class); public ModuleFactoryBundleTracker(BlankTransactionServiceTracker blankTransactionServiceTracker) { this.blankTransactionServiceTracker = blankTransactionServiceTracker; @@ -44,16 +41,15 @@ public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer lines = IOUtils.readLines(inputStream); - for (String factoryClassName : lines) { + try { + for (String factoryClassName : Resources.readLines(resource, Charsets.UTF_8)) { registerFactory(factoryClassName, bundle); } - } catch (Exception e) { - LOGGER.error("Error while reading {}", resource, e); + } catch (IOException e) { + LOG.error("Error while reading {}", resource, e); throw new RuntimeException(e); } } @@ -79,7 +75,7 @@ public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer clazz = bundle.loadClass(factoryClassName); if (ModuleFactory.class.isAssignableFrom(clazz)) { try { - LOGGER.debug("Registering {} in bundle {}", + LOG.debug("Registering {} in bundle {}", clazz.getName(), bundle); return bundle.getBundleContext().registerService( ModuleFactory.class.getName(), clazz.newInstance(), @@ -111,7 +107,7 @@ public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer