summaryrefslogtreecommitdiffstats
path: root/api/src
diff options
context:
space:
mode:
authorSimon Rettberg2018-03-20 12:40:24 +0100
committerSimon Rettberg2018-03-20 12:40:24 +0100
commit3950def62b4225e40d5a3c9df7a8c44171a9325f (patch)
tree33539041ed882ed098898f3a544e3d523dd5965b /api/src
parent[SystemCommandTask] try-with for stdout/err readers, close input after done (diff)
downloadtaskman-lite-3950def62b4225e40d5a3c9df7a8c44171a9325f.tar.gz
taskman-lite-3950def62b4225e40d5a3c9df7a8c44171a9325f.tar.xz
taskman-lite-3950def62b4225e40d5a3c9df7a8c44171a9325f.zip
[SystemCommandTask] Support changing environment
Diffstat (limited to 'api/src')
-rw-r--r--api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java b/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java
index 3e480de..18c8ecc 100644
--- a/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java
+++ b/api/src/main/java/org/openslx/taskmanager/api/SystemCommandTask.java
@@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
+import java.util.Map;
import org.apache.log4j.Logger;
@@ -47,6 +48,7 @@ public abstract class SystemCommandTask extends AbstractTask
ProcessBuilder pb = new ProcessBuilder( command );
pb.directory( new File( "/" ) );
+ initEnvironment( pb.environment() );
try {
@@ -208,6 +210,14 @@ public abstract class SystemCommandTask extends AbstractTask
protected abstract String[] initCommandLine();
/**
+ * Override this to modify the environment of the process to be started.
+ * @param environment
+ */
+ protected void initEnvironment( Map<String, String> environment )
+ {
+ }
+
+ /**
* Called when the process has been successfully started.
*/
protected void processStarted()