From a3ef37db9a61a090dc5d816c0053af908a9cce7e Mon Sep 17 00:00:00 2001 From: sjuarezgx Date: Wed, 18 May 2022 12:16:05 -0300 Subject: [PATCH] Add methods for reading environment variables --- .../src/main/java/com/genexus/GXRuntime.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/common/src/main/java/com/genexus/GXRuntime.java b/common/src/main/java/com/genexus/GXRuntime.java index 5cebd4661..4ad999b27 100644 --- a/common/src/main/java/com/genexus/GXRuntime.java +++ b/common/src/main/java/com/genexus/GXRuntime.java @@ -1,5 +1,8 @@ package com.genexus; +import com.genexus.util.*; +import java.util.Map; + public class GXRuntime { static public short getEnvironment() { return 1; // RuntimeEnvironment.Server @@ -17,4 +20,30 @@ static public void setExitCode(int value) { static public int getExitCode() { return exitCode; } + + public static String GetEnvironmentVariable(String key) { + String value = ""; + if (key != null && key.length() > 0){ + value = System.getenv(key); + } + return value; + } + public static GXProperties GetEnvironmentVariables() { + + Map env = System.getenv(); + GXProperties gxProperties = new GXProperties(); + for (String envName : env.keySet()) { + gxProperties.add(envName,env.get(envName) ); + } + return gxProperties; + } + + public static boolean HasEnvironmentVariable(String key) { + if (key != null && key.length() > 0){ + String value = System.getenv(key); + if (value != null && value.length() > 0) + return true; + } + return false; + } }