*
* @return the results of the command execution
*/
public StartCommandResponse execute(StartCommand command) {
org.rhq.core.util.exec.ProcessExecutor exec = new org.rhq.core.util.exec.ProcessExecutor();
StartCommandResponse response;
try {
StartCommand startCommand = new StartCommand(command);
ProcessToStart process = new ProcessToStart();
process.setArguments(command.getArguments());
process.setBackupOutputFile(command.isBackupOutputFile());
process.setCaptureOutput(command.isCaptureOutput());
process.setEnvironment(command.getEnvironment());
process.setInputDirectory(command.getInputDirectory());
process.setInputFile(command.getInputFile());
process.setOutputDirectory(command.getOutputDirectory());
process.setOutputFile(command.getOutputFile());
process.setProgramDirectory(command.getProgramDirectory());
process.setProgramExecutable(command.getProgramExecutable());
process.setProgramTitle(command.getProgramTitle());
process.setWaitForExit(command.getWaitForExit());
process.setWorkingDirectory(command.getWorkingDirectory());
ProcessExecutorResults results = exec.execute(process);
Integer exitCode = results.getExitCode();
Throwable error = results.getError();
if (error == null) {
response = new StartCommandResponse(startCommand, exitCode);
} else {
response = new StartCommandResponse(startCommand, error);
}
} catch (Exception e) {
response = new StartCommandResponse(command, e);
}
return response;
}