X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fosgi%2FOsgiBoot.java;h=f5b260caba404735f9f296830bab0e6e29c369bf;hb=71d0bea8d7aa3592f7f2b7c89bb8dd91b6d8bb6d;hp=2e96db3b37a769774f0c7b7d980ec1cb494549dd;hpb=a893bef98a50cbe52949dbea9e51881f436a4af4;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/osgi/OsgiBoot.java b/org.argeo.init/src/org/argeo/init/osgi/OsgiBoot.java index 2e96db3b3..f5b260cab 100644 --- a/org.argeo.init/src/org/argeo/init/osgi/OsgiBoot.java +++ b/org.argeo.init/src/org/argeo/init/osgi/OsgiBoot.java @@ -381,7 +381,23 @@ public class OsgiBoot implements OsgiBootConstants { for (String bsn : startLevels.get(level)) bundleStartLevels.put(bsn, level); } - for (Bundle bundle : bundleContext.getBundles()) { + + // keep only bundles with the highest version + Map startableBundles = new HashMap<>(); + bundles: for (Bundle bundle : bundleContext.getBundles()) { + if (bundle.getVersion() == null) + continue bundles; + String bsn = bundle.getSymbolicName(); + if (!startableBundles.containsKey(bsn)) { + startableBundles.put(bsn, bundle); + } else { + if (bundle.getVersion().compareTo(startableBundles.get(bsn).getVersion()) > 0) { + startableBundles.put(bsn, bundle); + } + } + } + + for (Bundle bundle : startableBundles.values()) { String bsn = bundle.getSymbolicName(); if (bundleStartLevels.containsKey(bsn)) { BundleStartLevel bundleStartLevel = bundle.adapt(BundleStartLevel.class); @@ -394,7 +410,7 @@ public class OsgiBoot implements OsgiBootConstants { OsgiBootUtils.error("Cannot mark " + bsn + " as started", e); } if (OsgiBootUtils.isDebug()) - OsgiBootUtils.debug(bsn + " starts at level " + level); + OsgiBootUtils.debug(bsn + " v" + bundle.getVersion() + " starts at level " + level); } } }