]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - base/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBoot.java
Add dep folder
[lgpl/argeo-commons.git] / base / runtime / org.argeo.osgi.boot / src / main / java / org / argeo / osgi / boot / OsgiBoot.java
index 8d07219dfb9d29cbcc8662d16b0055822bc60282..300ebb82dd48ba2802b3328cd832fd3a3dc1dbbe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2012 Mathieu Baudier
+ * Copyright (C) 2007-2012 Argeo GmbH
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -274,9 +274,9 @@ public class OsgiBoot {
        public void startBundles() {
                // default and active start levels from System properties
                Integer defaultStartLevel = new Integer(Integer.parseInt(OsgiBootUtils
-                               .getProperty(PROP_OSGI_BUNDLES_DEFAULTSTARTLEVEL)));
-               Integer activeStartLevel = new Integer(
-                               OsgiBootUtils.getProperty(PROP_OSGI_STARTLEVEL));
+                               .getProperty(PROP_OSGI_BUNDLES_DEFAULTSTARTLEVEL, "4")));
+               Integer activeStartLevel = new Integer(OsgiBootUtils.getProperty(
+                               PROP_OSGI_STARTLEVEL, "6"));
 
                SortedMap/* <Integer, List<String>> */startLevels = new TreeMap();
                computeStartLevels(startLevels, System.getProperties(),
@@ -414,11 +414,12 @@ public class OsgiBoot {
 
                // monitors that all bundles are started
                long beginMonitor = System.currentTimeMillis();
-               boolean allStarted = false;
+               boolean allStarted = !(startedBundles.size() > 0);
                List/* <String> */notStarted = new ArrayList();
-               while (allStarted
-                               && (System.currentTimeMillis() - beginMonitor) > defaultTimeout) {
+               while (!allStarted
+                               && (System.currentTimeMillis() - beginMonitor) < defaultTimeout) {
                        notStarted = new ArrayList();
+                       allStarted = true;
                        for (int i = 0; i < startedBundles.size(); i++) {
                                Bundle bundle = (Bundle) startedBundles.get(i);
                                // TODO check behaviour of lazs bundles
@@ -516,7 +517,7 @@ public class OsgiBoot {
                int currentState = bundle.getState();
                while (!(currentState == Bundle.RESOLVED || currentState == Bundle.ACTIVE)) {
                        long now = System.currentTimeMillis();
-                       if ((now - startBegin) > defaultTimeout)
+                       if ((now - startBegin) > defaultTimeout * 10)
                                throw new Exception("Bundle " + bundle.getSymbolicName()
                                                + " was not RESOLVED or ACTIVE after "
                                                + (now - startBegin) + "ms (originalState="
@@ -848,15 +849,15 @@ public class OsgiBoot {
 
        /** Creates an URL from a location */
        protected String locationToUrl(String baseUrl, String location) {
-               int extInd = location.lastIndexOf('.');
-               String ext = null;
-               if (extInd > 0)
-                       ext = location.substring(extInd);
-
-               if (baseUrl.startsWith("reference:") && ".jar".equals(ext))
-                       return "file:" + location;
-               else
-                       return baseUrl + location;
+               // int extInd = location.lastIndexOf('.');
+               // String ext = null;
+               // if (extInd > 0)
+               // ext = location.substring(extInd);
+               //
+               // if (baseUrl.startsWith("reference:") && ".jar".equals(ext))
+               // return "file:" + location;
+               // else
+               return baseUrl + location;
        }
 
        /** Transforms a relative path in a full system path. */