Package org.rhq.core.util.exec

Examples of org.rhq.core.util.exec.ProcessToStart


     * Spawns a new process using the Java Runtime API.
     *
     * @see SystemInfo#executeProcess(ProcessExecution)
     */
    public ProcessExecutionResults executeProcess(ProcessExecution processExecution) {
        ProcessToStart process = new ProcessToStart();
        ProcessExecutionResults executionResults = new ProcessExecutionResults();

        process.setProgramExecutable(processExecution.getExecutable());
        process.setCheckExecutableExists(processExecution.isCheckExecutableExists());
        process.setArguments(processExecution.getArgumentsAsArray());
        process.setEnvironment(processExecution.getEnvironmentVariablesAsArray());
        process.setWorkingDirectory(processExecution.getWorkingDirectory());
        process.setWaitForExit(Long.valueOf(processExecution.getWaitForCompletion()));
        process.setCaptureOutput(Boolean.valueOf(processExecution.isCaptureOutput()));
        process.setKillOnTimeout(Boolean.valueOf(processExecution.isKillOnTimeout()));

        if (processExecution.isCaptureOutput()) {
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            process.setOutputStream(outputStream);
            executionResults.setCapturedOutputStream(outputStream);
        }

        ProcessExecutorResults javaExecResults = javaExec.execute(process);
        executionResults.setExitCode(javaExecResults.getExitCode());
View Full Code Here


        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();
View Full Code Here

TOP

Related Classes of org.rhq.core.util.exec.ProcessToStart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.