Index: src/main/java/info/magnolia/cms/beans/config/PropertiesInitializer.java =================================================================== --- src/main/java/info/magnolia/cms/beans/config/PropertiesInitializer.java (revision 41323) +++ src/main/java/info/magnolia/cms/beans/config/PropertiesInitializer.java (working copy) @@ -39,6 +39,7 @@ import info.magnolia.module.ModuleManager; import info.magnolia.module.model.ModuleDefinition; import info.magnolia.module.model.PropertyDefinition; +import info.magnolia.objectfactory.Components; import java.io.File; import java.io.FileInputStream; @@ -54,7 +55,6 @@ import javax.servlet.ServletContext; -import info.magnolia.objectfactory.Components; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; @@ -98,6 +98,13 @@ */ public static final String CONTEXT_PARAM_PLACEHOLDER_PREFIX = "contextParam/"; //$NON-NLS-1$ + /** + * System property prefix, to obtain a property definition like ${systemProperty/property}, that can refer to any + * System property. + */ + public static final String SYSTEM_PROPERTY_PLACEHOLDER_PREFIX = "systemProperty/"; //$NON-NLS-1$ + + public static PropertiesInitializer getInstance() { return Components.getSingleton(PropertiesInitializer.class); } @@ -274,8 +281,9 @@ /** * Returns the property files configuration string passed, replacing all the needed values: ${servername} will be - * reaplced with the name of the server, ${webapp} will be replaced with webapp name, and ${contextAttribute/*} and - * ${contextParam/*} will be replaced with the corresponding attributes or parameters taken from servlet context. + * reaplced with the name of the server, ${webapp} will be replaced with webapp name, ${systemProperty/*} will be + * replaced with the corresponding system property, and ${contextAttribute/*} and ${contextParam/*} will be replaced + * with the corresponding attributes or parameters taken from servlet context. * This can be very useful for all those application servers that has multiple instances on the same server, like * WebSphere. Typical usage in this case: * WEB-INF/config/${servername}/${contextAttribute/com.ibm.websphere.servlet.application.host}/magnolia.properties @@ -322,6 +330,20 @@ } } + // Replacing system property (${systemProperty/something}) + String[] systemPropertiesNames = getNamesBetweenPlaceholders(propertiesFilesString, SYSTEM_PROPERTY_PLACEHOLDER_PREFIX); + if (systemPropertiesNames != null) { + for (String sysPropName : systemPropertiesNames) { + if (StringUtils.isNotBlank(sysPropName)) { + final String originalPlaceHolder = PLACEHOLDER_PREFIX + SYSTEM_PROPERTY_PLACEHOLDER_PREFIX + sysPropName + PLACEHOLDER_SUFFIX; + final String paramValue = System.getProperty(sysPropName); + if (paramValue != null) { + propertiesFilesString = propertiesFilesString.replace(originalPlaceHolder, paramValue); + } + } + } + } + return propertiesFilesString; }