private ProcessExecutionResults execute(String prefix, File executable, String... args) {
File homeDir = serverPluginConfig.getHomeDir();
File startScriptFile = executable.isAbsolute() ? executable : new File(homeDir, executable.getPath());
ProcessExecution processExecution = ProcessExecutionUtility.createProcessExecution(prefix, startScriptFile);
processExecution.setEnvironmentVariables(startScriptEnv);
List<String> arguments = processExecution.getArguments();
if (arguments == null) {
arguments = new ArrayList<String>();
processExecution.setArguments(arguments);
}
for (String arg : args) {
if (arg != null) {
arguments.add(arg);
}
}
// When running on Windows 9x, standalone.bat and domain.bat need the cwd to be the AS bin dir in order to find
// standalone.bat.conf and domain.bat.conf respectively.
processExecution.setWorkingDirectory(startScriptFile.getParent());
processExecution.setCaptureOutput(true);
processExecution.setWaitForCompletion(MAX_PROCESS_WAIT_TIME);
processExecution.setKillOnTimeout(false);
if (waitTime > 0) {
processExecution.setWaitForCompletion(waitTime);
} else if (waitTime < 0) {
processExecution.setWaitForCompletion(0);
}
processExecution.setKillOnTimeout(killOnTimeout);
if (LOG.isDebugEnabled()) {
LOG.debug("About to execute the following process: [" + processExecution + "]");
}