- for (int i = 0; i < urls.size(); i++) {
- String url = (String) urls.get(i);
- try {
- if (installedBundles.containsKey(url)) {
- Bundle bundle = (Bundle) installedBundles.get(url);
- // bundle.update();
- if (debug)
- debug("Bundle " + bundle.getSymbolicName()
- + " already installed from " + url);
- } else {
- Bundle bundle = bundleContext.installBundle(url);
- if (debug)
- debug("Installed bundle " + bundle.getSymbolicName()
- + " from " + url);
- }
- } catch (BundleException e) {
- String message = e.getMessage();
- if ((message.contains("Bundle \"" + SYMBOLIC_NAME_OSGI_BOOT
- + "\"") || message.contains("Bundle \""
- + SYMBOLIC_NAME_EQUINOX + "\""))
- && message.contains("has already been installed")) {
- // silent, in order to avoid warnings: we know that both
- // have already been installed...
- } else {
- OsgiBootUtils.warn("Could not install bundle from " + url
- + ": " + message);
- }
- if (debug)
- e.printStackTrace();
+
+ if (installInLexicographicOrder) {
+ SortedMap map = new TreeMap();
+ // reorder
+ for (int i = 0; i < urls.size(); i++) {
+ String url = (String) urls.get(i);
+ int index = url.lastIndexOf('/');
+ String fileName;
+ if (index >= 0)
+ fileName = url.substring(index + 1);
+ else
+ fileName = url;
+ map.put(fileName, url);
+ }
+
+ // install
+ Iterator keys = map.keySet().iterator();
+ while (keys.hasNext()) {
+ Object key = keys.next();
+ String url = map.get(key).toString();
+ installUrl(url, installedBundles);
+ }
+ } else {
+ for (int i = 0; i < urls.size(); i++) {
+ String url = (String) urls.get(i);
+ installUrl(url, installedBundles);