You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2011/12/21 21:48:56 UTC

svn commit: r1221872 - in /karaf/trunk: assemblies/features/framework/src/main/filtered-resources/resources/etc/config.properties main/src/main/java/org/apache/karaf/main/Main.java

Author: jbonofre
Date: Wed Dec 21 20:48:56 2011
New Revision: 1221872

URL: http://svn.apache.org/viewvc?rev=1221872&view=rev
Log:
[KARAF-1014] Add ${optionals} support in addition of ${includes}

Modified:
    karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/config.properties
    karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java

Modified: karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/config.properties
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/config.properties?rev=1221872&r1=1221871&r2=1221872&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/config.properties (original)
+++ karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/config.properties Wed Dec 21 20:48:56 2011
@@ -29,10 +29,19 @@
 #
 # Properties file inclusions (as a space separated list of relative paths)
 # Included files will override the values specified in this file
+# NB: ${includes} properties files are mandatory, it means that Karaf will not start
+# if the include file is not found
 #
 ${includes} = jre.properties custom.properties
 
 #
+# Properties file inclusions (as a space separated list of relative paths)
+# Included files will override the values specified in this file
+# NB: ${optionals} properties files are optionals, it means that Karaf will just
+# display a warning message but the bootstrap will be performed
+# ${optionals} = my.properties
+
+#
 # Framework selection properties
 #
 karaf.framework=felix

Modified: karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java
URL: http://svn.apache.org/viewvc/karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java?rev=1221872&r1=1221871&r2=1221872&view=diff
==============================================================================
--- karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java (original)
+++ karaf/trunk/main/src/main/java/org/apache/karaf/main/Main.java Wed Dec 21 20:48:56 2011
@@ -195,7 +195,9 @@ public class Main {
 
     public static final String PROPERTY_LOCK_CLASS_DEFAULT = SimpleFileLock.class.getName();
 
-    public static final String INCLUDES_PROPERTY = "${includes}";
+    public static final String INCLUDES_PROPERTY = "${includes}"; // mandatory includes
+    
+    public static final String OPTIONALS_PROPERTY = "${optionals}"; // optionals includes
 
     public static final String KARAF_ACTIVATOR = "Karaf-Activator";
 
@@ -939,13 +941,13 @@ public class Main {
             is = configPropURL.openConnection().getInputStream();
             configProps.load(is);
             is.close();
-        }
-        catch (FileNotFoundException ex) {
+        } catch (FileNotFoundException ex) {
             if (failIfNotFound) {
                 throw ex;
+            } else {
+                System.err.println("WARN: " + configPropURL + " is not found, so not loaded");
             }
-        }
-        catch (Exception ex) {
+        } catch (Exception ex) {
             System.err.println("Error loading config properties from " + configPropURL);
             System.err.println("Main: " + ex);
             return configProps;
@@ -976,6 +978,23 @@ public class Main {
             }
             configProps.remove(INCLUDES_PROPERTY);
         }
+        String optionals = configProps.getProperty(OPTIONALS_PROPERTY);
+        if (optionals != null) {
+            StringTokenizer st = new StringTokenizer(optionals, "\" ", true);
+            if (st.countTokens() > 0) {
+                String location;
+                do {
+                    location = nextLocation(st);
+                    if (location != null) {
+                        URL url = new URL(configPropURL, location);
+                        Properties props = loadPropertiesFile(url, false);
+                        configProps.putAll(props);
+                    }
+                }
+                while (location != null);
+            }
+            configProps.remove(OPTIONALS_PROPERTY);
+        }
         for (Enumeration e = configProps.propertyNames(); e.hasMoreElements();) {
             Object key = e.nextElement();
             if (key instanceof String) {