summaryrefslogtreecommitdiff
path: root/src/com/p4square/grow/config
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2016-04-09 14:20:48 -0700
committerJesse Morgan <jesse@jesterpm.net>2016-04-09 14:20:48 -0700
commitbbf907e51dfcf157bdee24dead1d531122aa25db (patch)
tree86e8e100046ec3461d8d53e448107cf0145388e2 /src/com/p4square/grow/config
parent2e76039d4ecaff8d2ed40b67c309c2498ff4a1d5 (diff)
parentbddf96d0fdd60faa1905d374eef8a122771f57a3 (diff)
Merge pull request #9 from PuyallupFoursquare/ccb-support
Adding support for Church Community Builder
Diffstat (limited to 'src/com/p4square/grow/config')
-rw-r--r--src/com/p4square/grow/config/Config.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/com/p4square/grow/config/Config.java b/src/com/p4square/grow/config/Config.java
index e89990b..2fc2ea3 100644
--- a/src/com/p4square/grow/config/Config.java
+++ b/src/com/p4square/grow/config/Config.java
@@ -35,12 +35,27 @@ public class Config {
private Properties mProperties;
/**
- * Construct a new Config object. Domain defaults to prod.
+ * Construct a new Config object.
+ *
+ * Sets the domain to the value of the system property CONFIG_DOMAIN, if present.
+ * If the system property is not set then the environment variable CONFIG_DOMAIN is checked.
+ * If neither are set the domain defaults to prod.
*/
public Config() {
- mDomain = "prod";
- mProperties = new Properties();
+ // Check the command line for a domain property.
+ mDomain = System.getProperty("CONFIG_DOMAIN");
+
+ // If the domain was not set with a property, check for an environment variable.
+ if (mDomain == null) {
+ mDomain = System.getenv("CONFIG_DOMAIN");
+ }
+
+ // If neither were set, default to prod
+ if (mDomain == null) {
+ mDomain = "prod";
+ }
+ mProperties = new Properties();
}
/**
@@ -62,7 +77,7 @@ public class Config {
/**
* Load properties from a file.
- * Any exceptions are logged and suppressed.
+ * Any exception are logged and suppressed.
*/
public void updateConfig(String propertyFilename) {
final File propFile = new File(propertyFilename);
@@ -114,6 +129,13 @@ public class Config {
return result;
}
+ // Environment variables can also override configs
+ result = System.getenv(key);
+ if (result != null) {
+ LOG.debug("Reading System.getenv(" + key + "). Got result = { " + result + " }");
+ return result;
+ }
+
final String domainKey = mDomain + "." + key;
result = mProperties.getProperty(domainKey);
if (result != null) {