/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.slf4j.LoggerFactory;
/**
- * Tracks bundles and attempts to retrieve YangModuleInfo, which is then fed into ModuleInfoRegistry
+ * Tracks bundles and attempts to retrieve YangModuleInfo, which is then fed
+ * into ModuleInfoRegistry.
*/
-public final class ModuleInfoBundleTracker implements AutoCloseable,
- BundleTrackerCustomizer<Collection<ObjectRegistration<YangModuleInfo>>> {
+public final class ModuleInfoBundleTracker
+ implements AutoCloseable, BundleTrackerCustomizer<Collection<ObjectRegistration<YangModuleInfo>>> {
private static final Logger LOG = LoggerFactory.getLogger(ModuleInfoBundleTracker.class);
private final RefreshingSCPModuleInfoRegistry moduleInfoRegistry;
- private BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> bundleTracker;
+ private BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> tracker;
private boolean starting;
public ModuleInfoBundleTracker(final RefreshingSCPModuleInfoRegistry moduleInfoRegistry) {
LOG.debug("ModuleInfoBundleTracker open starting with bundleTracker {}", bundleTracker);
if (bundleTracker != null) {
- this.bundleTracker = bundleTracker;
+ this.tracker = bundleTracker;
starting = true;
bundleTracker.open();
@Override
public void close() {
- if (bundleTracker != null) {
- bundleTracker.close();
- bundleTracker = null;
+ if (tracker != null) {
+ tracker.close();
+ tracker = null;
}
}
@Override
+ @SuppressWarnings("IllegalCatch")
public Collection<ObjectRegistration<YangModuleInfo>> addingBundle(final Bundle bundle, final BundleEvent event) {
URL resource = bundle.getEntry(YANG_MODULE_INFO_SERVICE_PATH);
LOG.debug("Got addingBundle({}) with YangModelBindingProvider resource {}", bundle, resource);
registrations.add(moduleInfoRegistry.registerModuleInfo(moduleInfo));
}
- if(!starting) {
+ if (!starting) {
moduleInfoRegistry.updateService();
}
} catch (final IOException e) {
}
@Override
+ @SuppressWarnings("IllegalCatch")
public void removedBundle(final Bundle bundle, final BundleEvent event,
final Collection<ObjectRegistration<YangModuleInfo>> regs) {
if (regs == null) {
if (!YangModelBindingProvider.class.isAssignableFrom(clazz)) {
errorMessage = logMessage("Class {} does not implement {} in bundle {}", clazz,
- YangModelBindingProvider.class, bundle);
+ YangModelBindingProvider.class, bundle);
throw new IllegalStateException(errorMessage);
}
final YangModelBindingProvider instance;
throw new IllegalStateException(errorMessage, e);
}
- try{
+ try {
return instance.getModuleInfo();
} catch (NoClassDefFoundError | ExceptionInInitializerError e) {
throw new IllegalStateException("Error while executing getModuleInfo on " + instance, e);
try {
return bundle.loadClass(moduleInfoClass);
} catch (final ClassNotFoundException e) {
- String errorMessage = logMessage("Could not find class {} in bundle {}, reason {}", moduleInfoClass,
- bundle, e);
+ String errorMessage = logMessage("Could not find class {} in bundle {}, reason {}", moduleInfoClass, bundle,
+ e);
throw new IllegalStateException(errorMessage);
}
}