package org.opendaylight.controller.config.manager.impl.osgi.mapping;
import static java.lang.String.format;
package org.opendaylight.controller.config.manager.impl.osgi.mapping;
import static java.lang.String.format;
import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.osgi.framework.Bundle;
import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.osgi.framework.Bundle;
- public GeneratedClassLoadingStrategy getModuleInfoLoadingStrategy() {
- return moduleInfoLoadingStrategy;
+ private final ModuleInfoRegistry moduleInfoRegistry;
+
+ public ModuleInfoBundleTracker(ModuleInfoRegistry moduleInfoRegistry) {
+ this.moduleInfoRegistry = moduleInfoRegistry;
}
@Override
public Collection<ObjectRegistration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName());
}
@Override
public Collection<ObjectRegistration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName());
- try (InputStream inputStream = resource.openStream()) {
- List<String> lines = IOUtils.readLines(inputStream);
- for (String moduleInfoName : lines) {
+ try {
+ for (String moduleInfoName : Resources.readLines(resource, Charsets.UTF_8)) {
+ LOG.trace("Retrieve ModuleInfo({}, {})", moduleInfoName, bundle);
-
-
- } catch (Exception e) {
- logger.error("Error while reading {}", resource, e);
+ } catch (IOException e) {
+ LOG.error("Error while reading {}", resource, e);
return registrations;
}
@Override
public void modifiedBundle(Bundle bundle, BundleEvent event, Collection<ObjectRegistration<YangModuleInfo>> object) {
return registrations;
}
@Override
public void modifiedBundle(Bundle bundle, BundleEvent event, Collection<ObjectRegistration<YangModuleInfo>> object) {
errorMessage = logMessage("Could not instantiate {} in bundle {}, reason {}", moduleInfoClass, bundle, e);
throw new IllegalStateException(errorMessage, e);
} catch (IllegalAccessException e) {
errorMessage = logMessage("Could not instantiate {} in bundle {}, reason {}", moduleInfoClass, bundle, e);
throw new IllegalStateException(errorMessage, e);
} catch (IllegalAccessException e) {
- errorMessage = logMessage("Illegal access during instatiation of class {} in bundle {}, reason {}",
+ errorMessage = logMessage("Illegal access during instantiation of class {} in bundle {}, reason {}",
moduleInfoClass, bundle, e);
throw new IllegalStateException(errorMessage, e);
}
moduleInfoClass, bundle, e);
throw new IllegalStateException(errorMessage, e);
}
- String errorMessage = logMessage("Could not find class {} in bunde {}, reason {}", moduleInfoClass, bundle, e);
+ String errorMessage = logMessage("Could not find class {} in bundle {}, reason {}", moduleInfoClass, bundle, e);
throw new IllegalStateException(errorMessage);
}
}
public static String logMessage(String slfMessage, Object... params) {
throw new IllegalStateException(errorMessage);
}
}
public static String logMessage(String slfMessage, Object... params) {
String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
return format(formatMessage, params);
}
String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
return format(formatMessage, params);
}