Auto-property handling now installs bundles into the default bundle start
level if a start level is not specified. (FELIX-359)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@583501 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index 2fa49af..a0f8635 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -3604,9 +3604,19 @@
         for (Iterator i = m_configMap.keySet().iterator(); i.hasNext(); )
         {
             String key = (String) i.next();
-            if (key.startsWith(FelixConstants.AUTO_INSTALL_PROP))
+
+            // Ignore all keys that are not the auto-install property.
+            if (!key.startsWith(FelixConstants.AUTO_INSTALL_PROP))
             {
-                int startLevel = 1;
+                continue;
+            }
+
+            // If the auto-install property does not have a start level,
+            // then assume it is the default bundle start level, otherwise
+            // parse the specified start level.
+            int startLevel = getInitialBundleStartLevel();
+            if (!key.equals(FelixConstants.AUTO_INSTALL_PROP))
+            {
                 try
                 {
                     startLevel = Integer.parseInt(key.substring(key.lastIndexOf('.') + 1));
@@ -3615,29 +3625,30 @@
                 {
                     m_logger.log(Logger.LOG_ERROR, "Invalid property: " + key);
                 }
-                StringTokenizer st = new StringTokenizer((String) m_configMap.get(key), "\" ",true);
-                if (st.countTokens() > 0)
+            }
+
+            StringTokenizer st = new StringTokenizer((String) m_configMap.get(key), "\" ",true);
+            if (st.countTokens() > 0)
+            {
+                String location = null;
+                do
                 {
-                    String location = null;
-                    do
+                    location = nextLocation(st);
+                    if (location != null)
                     {
-                        location = nextLocation(st);
-                        if (location != null)
+                        try
                         {
-                            try
-                            {
-                                FelixBundle b = (FelixBundle) installBundle(location, null);
-                                b.getInfo().setStartLevel(startLevel);
-                            }
-                            catch (Exception ex)
-                            {
-                                m_logger.log(
-                                    Logger.LOG_ERROR, "Auto-properties install.", ex);
-                            }
+                            FelixBundle b = (FelixBundle) installBundle(location, null);
+                            b.getInfo().setStartLevel(startLevel);
+                        }
+                        catch (Exception ex)
+                        {
+                            m_logger.log(
+                                Logger.LOG_ERROR, "Auto-properties install.", ex);
                         }
                     }
-                    while (location != null);
                 }
+                while (location != null);
             }
         }
 
@@ -3651,9 +3662,19 @@
         for (Iterator i = m_configMap.keySet().iterator(); i.hasNext(); )
         {
             String key = (String) i.next();
-            if (key.startsWith(FelixConstants.AUTO_START_PROP))
+
+            // Ignore all keys that are not the auto-start property.
+            if (!key.startsWith(FelixConstants.AUTO_START_PROP))
             {
-                int startLevel = 1;
+                continue;
+            }
+
+            // If the auto-start property does not have a start level,
+            // then assume it is the default bundle start level, otherwise
+            // parse the specified start level.
+            int startLevel = getInitialBundleStartLevel();
+            if (!key.equals(FelixConstants.AUTO_START_PROP))
+            {
                 try
                 {
                     startLevel = Integer.parseInt(key.substring(key.lastIndexOf('.') + 1));
@@ -3662,28 +3683,29 @@
                 {
                     m_logger.log(Logger.LOG_ERROR, "Invalid property: " + key);
                 }
-                StringTokenizer st = new StringTokenizer((String) m_configMap.get(key), "\" ",true);
-                if (st.countTokens() > 0)
+            }
+
+            StringTokenizer st = new StringTokenizer((String) m_configMap.get(key), "\" ",true);
+            if (st.countTokens() > 0)
+            {
+                String location = null;
+                do
                 {
-                    String location = null;
-                    do
+                    location = nextLocation(st);
+                    if (location != null)
                     {
-                        location = nextLocation(st);
-                        if (location != null)
+                        try
                         {
-                            try
-                            {
-                                FelixBundle b = (FelixBundle) installBundle(location, null);
-                                b.getInfo().setStartLevel(startLevel);
-                            }
-                            catch (Exception ex)
-                            {
-                                m_logger.log(Logger.LOG_ERROR, "Auto-properties install.", ex);
-                            }
+                            FelixBundle b = (FelixBundle) installBundle(location, null);
+                            b.getInfo().setStartLevel(startLevel);
+                        }
+                        catch (Exception ex)
+                        {
+                            m_logger.log(Logger.LOG_ERROR, "Auto-properties install.", ex);
                         }
                     }
-                    while (location != null);
                 }
+                while (location != null);
             }
         }