-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support environment variables for all supported system properties
in a uniform way. A utility function was added to read from both System.properties and System.env. If a property starts with "org.daisy.pipeline", the function first looks for an environment variable and falls back to a system property. Otherwise it looks only for a system property. For example, if the key is "org.daisy.pipeline.ws.host", an environment variable "PIPELINE2_WS_HOST" will have precedence over the system property.
- Loading branch information
Showing
19 changed files
with
167 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
framework-core/src/main/java/org/daisy/pipeline/properties/Properties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.daisy.pipeline.properties; | ||
|
||
import java.util.Map; | ||
|
||
public class Properties { | ||
|
||
private final static java.util.Properties systemProperties = System.getProperties(); | ||
private final static Map<String,String> systemEnv = System.getenv(); | ||
|
||
public static String getProperty(String key) { | ||
return getProperty(key, null); | ||
} | ||
|
||
public static String getProperty(String key, String defaultValue) { | ||
if (key == null) | ||
throw new NullPointerException(); | ||
if (key.startsWith("org.daisy.pipeline.")) { | ||
String envKey = "PIPELINE2_" + key.substring(19).replace('.', '_').toUpperCase(); | ||
if (systemEnv.containsKey(envKey)) | ||
return systemEnv.get(envKey); | ||
} | ||
return systemProperties.getProperty(key, defaultValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 38 additions & 17 deletions
55
webservice-utils/src/main/java/org/daisy/pipeline/webserviceutils/Properties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
package org.daisy.pipeline.webserviceutils; | ||
|
||
public interface Properties { | ||
public static final String MAX_REQUEST_TIME = "org.daisy.pipeline.ws.maxrequesttime"; | ||
public static final String TMPDIR = "org.daisy.pipeline.ws.tmpdir"; | ||
public static final String AUTHENTICATION = "org.daisy.pipeline.ws.authentication"; | ||
public static final String LOCALFS= "org.daisy.pipeline.ws.localfs"; | ||
public static final String FRAMEWORK_VERSION="org.daisy.pipeline.version"; | ||
public static final String JAVA_IO_TMPDIR = "java.io.tmpdir"; | ||
public static final String PORT = "org.daisy.pipeline.ws.port"; | ||
public static final String PATH = "org.daisy.pipeline.ws.path"; | ||
public static final String HOST = "org.daisy.pipeline.ws.host"; | ||
public static final String SSL= "org.daisy.pipeline.ws.ssl"; | ||
public static final String SSL_KEYSTORE= "org.daisy.pipeline.ws.ssl.keystore"; | ||
public static final String SSL_KEYSTOREPASSWORD= "org.daisy.pipeline.ws.ssl.keystorepassword"; | ||
public static final String CLEAN_UP_ON_START_UP = "org.daisy.pipeline.ws.cleanuponstartup"; | ||
public enum Properties { | ||
|
||
public static final String SSL_KEYPASSWORD= "org.daisy.pipeline.ws.ssl.keypassword"; | ||
public static final String CLIENT_KEY= "org.daisy.pipeline.ws.authentication.key"; | ||
public static final String CLIENT_SECRET= "org.daisy.pipeline.ws.authentication.secret"; | ||
MAX_REQUEST_TIME("org.daisy.pipeline.ws.maxrequesttime"), | ||
TMPDIR("org.daisy.pipeline.ws.tmpdir"), | ||
AUTHENTICATION("org.daisy.pipeline.ws.authentication"), | ||
LOCALFS("org.daisy.pipeline.ws.localfs"), | ||
FRAMEWORK_VERSION("org.daisy.pipeline.version"), | ||
PORT("org.daisy.pipeline.ws.port"), | ||
PATH("org.daisy.pipeline.ws.path"), | ||
HOST("org.daisy.pipeline.ws.host"), | ||
SSL("org.daisy.pipeline.ws.ssl"), | ||
SSL_KEYSTORE("org.daisy.pipeline.ws.ssl.keystore"), | ||
SSL_KEYSTOREPASSWORD("org.daisy.pipeline.ws.ssl.keystorepassword"), | ||
CLEAN_UP_ON_START_UP("org.daisy.pipeline.ws.cleanuponstartup"), | ||
SSL_KEYPASSWORD("org.daisy.pipeline.ws.ssl.keypassword"), | ||
CLIENT_KEY("org.daisy.pipeline.ws.authentication.key"), | ||
CLIENT_SECRET("org.daisy.pipeline.ws.authentication.secret"); | ||
|
||
private final String key; | ||
|
||
private Properties(String key) { | ||
this.key = key; | ||
} | ||
|
||
public String get() { | ||
return org.daisy.pipeline.properties.Properties.getProperty(key); | ||
} | ||
|
||
public String get(String defaultValue) { | ||
return org.daisy.pipeline.properties.Properties.getProperty(key, defaultValue); | ||
} | ||
|
||
public String getName() { | ||
return key; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return key; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.