import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.concurrent.GuardedBy;
+import org.checkerframework.checker.lock.qual.GuardedBy;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.dom.broker.schema.ScanningSchemaServiceProvider;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.BundleTracker;
import org.osgi.util.tracker.BundleTrackerCustomizer;
private static final Logger LOG = LoggerFactory.getLogger(OsgiBundleScanningSchemaService.class);
private static final AtomicReference<OsgiBundleScanningSchemaService> GLOBAL_INSTANCE = new AtomicReference<>();
- private static final long FRAMEWORK_BUNDLE_ID = 0;
private final BundleScanner scanner = new BundleScanner();
private final BundleContext context;
}
@VisibleForTesting
- public static void destroyInstance() throws Exception {
+ public static void destroyInstance() {
final OsgiBundleScanningSchemaService instance = GLOBAL_INSTANCE.getAndSet(null);
if (instance != null) {
instance.closeInstance();
@Override
public Iterable<Registration> addingBundle(final Bundle bundle, final BundleEvent event) {
- if (bundle.getBundleId() == FRAMEWORK_BUNDLE_ID) {
+ if (bundle.getBundleId() == Constants.SYSTEM_BUNDLE_ID) {
return Collections.emptyList();
}
urls.add(u);
LOG.debug("Registered {}", u);
} catch (final Exception e) {
- LOG.warn("Failed to register {}, ignoring it", e);
+ LOG.warn("Failed to register {}, ignoring it", u, e);
}
}
@Override
public void modifiedBundle(final Bundle bundle, final BundleEvent event, final Iterable<Registration> object) {
- if (bundle.getBundleId() == FRAMEWORK_BUNDLE_ID) {
+ if (bundle.getBundleId() == Constants.SYSTEM_BUNDLE_ID) {
LOG.debug("Framework bundle {} got event {}", bundle, event.getType());
if ((event.getType() & BundleEvent.STOPPING) != 0) {
LOG.info("OSGi framework is being stopped, halting bundle scanning");