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:56:27 UTC
svn commit: r1221877 - in /karaf/branches/karaf-2.2.x:
assemblies/apache-karaf/src/main/filtered-resources/etc/config.properties
main/src/main/java/org/apache/karaf/main/Main.java
Author: jbonofre
Date: Wed Dec 21 20:56:26 2011
New Revision: 1221877
URL: http://svn.apache.org/viewvc?rev=1221877&view=rev
Log:
[KARAF-1014] Introduction of ${optionals} in addition of ${includes}
Modified:
karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/etc/config.properties
karaf/branches/karaf-2.2.x/main/src/main/java/org/apache/karaf/main/Main.java
Modified: karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/etc/config.properties
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/etc/config.properties?rev=1221877&r1=1221876&r2=1221877&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/etc/config.properties (original)
+++ karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/filtered-resources/etc/config.properties Wed Dec 21 20:56:26 2011
@@ -29,10 +29,21 @@
#
# 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/branches/karaf-2.2.x/main/src/main/java/org/apache/karaf/main/Main.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/main/src/main/java/org/apache/karaf/main/Main.java?rev=1221877&r1=1221876&r2=1221877&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/main/src/main/java/org/apache/karaf/main/Main.java (original)
+++ karaf/branches/karaf-2.2.x/main/src/main/java/org/apache/karaf/main/Main.java Wed Dec 21 20:56:26 2011
@@ -178,7 +178,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
Logger LOG = Logger.getLogger(this.getClass().getName());
@@ -915,13 +917,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;
@@ -952,6 +954,22 @@ 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) {