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;
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
LOG.trace("Got addingBundle event of bundle {}, resource {}, event {}",
bundle, resource, event);
if (resource != null) {
- try (InputStream inputStream = resource.openStream()) {
- List<String> lines = IOUtils.readLines(inputStream);
- for (String factoryClassName : lines) {
+ try {
+ for (String factoryClassName : Resources.readLines(resource, Charsets.UTF_8)) {
registerFactory(factoryClassName, bundle);
}
- } catch (Exception e) {
+ } catch (IOException e) {
LOG.error("Error while reading {}", resource, e);
throw new RuntimeException(e);
}