]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.osgi/src/main/java/org/argeo/slc/osgi/BundlesManager.java
Use listener to track services
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.osgi / src / main / java / org / argeo / slc / osgi / BundlesManager.java
index 22d1e4b455b347953b2b38d0806c13cbd7e46f3f..e24b7223b7736299125d5aae7f6ddd29b5a4d0f6 100644 (file)
@@ -299,16 +299,23 @@ public class BundlesManager implements BundleContextAware, FrameworkListener,
                        Assert.isTrue(
                                        osgiBundle.getName().equals(bundle.getSymbolicName()),
                                        "symbolic name consistent");
-                       Assert.isTrue(osgiBundle.getVersion().equals(
-                                       bundle.getHeaders().get(Constants.BUNDLE_VERSION)),
-                                       "version consistent");
+                       if (osgiBundle.getVersion() != null)
+                               Assert.isTrue(osgiBundle.getVersion().equals(
+                                               bundle.getHeaders().get(Constants.BUNDLE_VERSION)),
+                                               "version consistent");
                } else {
-                       for (Bundle b : bundleContext.getBundles()) {
+                       bundles: for (Bundle b : bundleContext.getBundles()) {
                                if (b.getSymbolicName().equals(osgiBundle.getName())) {
+                                       if (osgiBundle.getVersion() == null) {
+                                               bundle = b;
+                                               break bundles;
+                                       }
+
                                        if (b.getHeaders().get(Constants.BUNDLE_VERSION).equals(
                                                        osgiBundle.getVersion())) {
                                                bundle = b;
                                                osgiBundle.setInternalBundleId(b.getBundleId());
+                                               break bundles;
                                        }
                                }
                        }