Use osgi-core constants 63/87963/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 26 Feb 2020 10:38:07 +0000 (11:38 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 26 Feb 2020 14:12:03 +0000 (14:12 +0000)
Just to keep things consistent, use OSGi's Constants class to get
the bundle id for framework (i.e. SYSTEM_BUNDLE_ID).

Change-Id: I18dae474c944f29ebb32203a12db1c96c2e1483f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a246443e10cc43adace7bc36fdf8014d76010389)

dom/mdsal-dom-schema-service-osgi/src/main/java/org/opendaylight/mdsal/dom/schema/service/osgi/OsgiBundleScanningSchemaService.java

index d1917c0bef4543d5be8aeec42b0cb3ae26b06558..727d790ab2d7a883a809ed3ee5109ca47cec8296 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 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;
@@ -40,7 +41,6 @@ public final class OsgiBundleScanningSchemaService extends ScanningSchemaService
 
     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;
@@ -125,7 +125,7 @@ public final class OsgiBundleScanningSchemaService extends ScanningSchemaService
         @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();
             }
 
@@ -158,7 +158,7 @@ public final class OsgiBundleScanningSchemaService extends ScanningSchemaService
 
         @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");