X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2FService.java;h=c63fdcd376daffa6ac0492f78ae38bef28ff5fd9;hb=9fd6762a7ac6bb5102dcd2c5a3bc876aa5c942c4;hp=cab85d02ff3e8eefa19317916ebf0de3f286af30;hpb=6bf0278e427c0a9fe9d922fe19593b89892cb03e;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/Service.java b/org.argeo.init/src/org/argeo/init/Service.java index cab85d02f..c63fdcd37 100644 --- a/org.argeo.init/src/org/argeo/init/Service.java +++ b/org.argeo.init/src/org/argeo/init/Service.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.Properties; +import java.util.TreeMap; import org.argeo.init.logging.ThinLoggerFinder; import org.argeo.init.osgi.OsgiBoot; @@ -19,6 +20,8 @@ import org.argeo.init.osgi.OsgiRuntimeContext; public class Service { private final static Logger logger = System.getLogger(Service.class.getName()); + final static String FILE_SYSTEM_PROPERTIES = "system.properties"; + public final static String PROP_ARGEO_INIT_MAIN = "argeo.init.main"; private static RuntimeContext runtimeContext = null; @@ -51,7 +54,7 @@ public class Service { if (configArea != null) { Path configAreaPath = Paths.get(configArea); - Path additionalSystemPropertiesPath = configAreaPath.resolve("system.properties"); + Path additionalSystemPropertiesPath = configAreaPath.resolve(FILE_SYSTEM_PROPERTIES); if (Files.exists(additionalSystemPropertiesPath)) { Properties properties = new Properties(); try (InputStream in = Files.newInputStream(additionalSystemPropertiesPath)) { @@ -70,6 +73,8 @@ public class Service { + currentValue + " instead of " + value + ". Ignoring new value."); } else { System.setProperty(key.toString(), value); + logger.log(Logger.Level.TRACE, () -> "Added " + key + "=" + value + + " to system properties, from " + additionalSystemPropertiesPath.getFileName()); } } ThinLoggerFinder.reloadConfiguration(); @@ -79,6 +84,27 @@ public class Service { Map config = new HashMap<>(); config.put(PROP_ARGEO_INIT_MAIN, "true"); + // add OSGi system properties to the configuration + sysprops: for (Object key : new TreeMap<>(System.getProperties()).keySet()) { + String keyStr = key.toString(); + switch (keyStr) { + case OsgiBoot.PROP_OSGI_CONFIGURATION_AREA: + case OsgiBoot.PROP_OSGI_SHARED_CONFIGURATION_AREA: + case OsgiBoot.PROP_OSGI_INSTANCE_AREA: + // we should already have dealt with those + continue sysprops; + default: + } + + if (keyStr.startsWith("osgi.") || keyStr.startsWith("org.osgi.") || keyStr.startsWith("eclipse.") + || keyStr.startsWith("org.eclipse.equinox.") || keyStr.startsWith("felix.")) { + String value = System.getProperty(keyStr); + config.put(keyStr, value); + logger.log(Logger.Level.TRACE, + () -> "Added " + key + "=" + value + " to configuration, from system properties"); + } + } + try { try { if (stateArea != null) @@ -106,6 +132,7 @@ public class Service { logger.log(Logger.Level.DEBUG, "Argeo Init stopped with PID " + pid); } + /** The root runtime context in this JVM. */ public static RuntimeContext getRuntimeContext() { return runtimeContext; }