Skip to content

Commit 55cf746

Browse files
authored
Allow set Storage Name and Classname using env vars (#972)
Issue 204656
1 parent 1676c6d commit 55cf746

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

java/src/main/java/com/genexus/util/GXServices.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class GXServices {
2020
public static final String DATA_ACCESS_SERVICE = "DataAccess";
2121
private static final String SERVICES_FILE = "CloudServices.config";
2222
private static final String SERVICES_DEV_FILE = "CloudServices.dev.config";
23+
private static final String STORAGE_DEFAULT_NAME = "STORAGE_DEFAULT_NAME";
24+
private static final String STORAGE_DEFAULT_CLASSNAME = "STORAGE_DEFAULT_CLASSNAME";
2325
private static GXServices instance;
2426
private Hashtable<String, GXService> services = new Hashtable<String, GXService>();
2527

@@ -124,6 +126,11 @@ private void processService(XMLReader reader) {
124126
result = reader.readType(1, "ClassName");
125127
String className = new String(reader.getValue());
126128

129+
if (type.equals(STORAGE_SERVICE)) {
130+
name = getEnvValue(STORAGE_DEFAULT_NAME, name);
131+
className = getEnvValue(STORAGE_DEFAULT_CLASSNAME, className);
132+
}
133+
127134
boolean allowMultiple = false;
128135
reader.read();
129136
if (reader.getName() == "AllowMultiple")
@@ -172,4 +179,11 @@ public GXService get(String name) {
172179
return services.get(name);
173180
}
174181

182+
private String getEnvValue(String envVar, String defaultValue) {
183+
String value = System.getenv(envVar);
184+
if (value == null){
185+
value = defaultValue;
186+
}
187+
return value;
188+
}
175189
}

0 commit comments

Comments
 (0)