Author: tom.baeyens(a)jboss.com
Date: 2009-08-28 08:44:48 -0400 (Fri, 28 Aug 2009)
New Revision: 5576
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/Launcher.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/StartTomcatTask.java
Log:
moved setting of the environment variable (in the StartTomcatTask) from the ant VM to the
new process created in the launcher
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/Launcher.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/Launcher.java 2009-08-28
09:37:16 UTC (rev 5575)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/Launcher.java 2009-08-28
12:44:48 UTC (rev 5576)
@@ -25,6 +25,8 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
@@ -35,6 +37,7 @@
String[] command;
String endMsg;
File dir;
+ Map<String, String> environmentVariables = new HashMap<String, String>();
public Launcher(Task task, String[] command, String endMsg, String dir) {
this.task = task;
@@ -50,10 +53,15 @@
}
try {
task.log("starting '" + logCommand + "'...");
- Process process = new ProcessBuilder(command)
+ ProcessBuilder processBuilder = new ProcessBuilder(command)
.redirectErrorStream(true)
- .directory(dir)
- .start();
+ .directory(dir);
+
+ if (!environmentVariables.isEmpty()) {
+ processBuilder.environment().putAll(environmentVariables);
+ }
+
+ Process process = processBuilder.start();
BufferedReader reader = new BufferedReader(new
InputStreamReader(process.getInputStream()));
String line = "";
@@ -67,4 +75,10 @@
throw new BuildException("couldn't start '" + logCommand +
"'", e);
}
}
+
+ public void setEnvironmentVariable(String variableName, String value) {
+ environmentVariables.put(variableName, value);
+ }
+
+
}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/StartTomcatTask.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/StartTomcatTask.java 2009-08-28
09:37:16 UTC (rev 5575)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/StartTomcatTask.java 2009-08-28
12:44:48 UTC (rev 5576)
@@ -51,11 +51,9 @@
throw new BuildException( "os '" + os + "' not supported
in the start-tomcat task." );
}
- // CATALINA_HOME MUST BE SET for tomcat to boot
- System.setProperty("CATALINA_HOME", getTomcatHome());
-
// launch the command and wait till the END_MESSAGE appears
- Thread launcher = new Launcher(this, command, END_MESSAGE, null);
+ Launcher launcher = new Launcher(this, command, END_MESSAGE, null);
+ launcher.setEnvironmentVariable("CATALINA_HOME", getTomcatHome());
launcher.start();
launcher.join();
Show replies by date