eu.scape_project.pit.proc
Class ProcessRunner

java.lang.Object
  extended by eu.scape_project.pit.proc.ProcessRunner
All Implemented Interfaces:
Runnable

public class ProcessRunner
extends Object
implements Runnable

ProcessRunner class.

Native command executor. Based on ProcessBuilder.

Use the Assessor methods to configure the Enviroment, input, collecting behavoiur, timeout and startingDir. Use the getters to get the output and error streams as strings, along with the return code and if the process timed out.

This code is not yet entirely thread safe. Be sure to only call a given processRunner from one thread, and do not reuse it.

This class is based on the PLANETS class eu.planets_project.services.utils.ProcessRunner

Version:
${global_wrapper_version}
Author:
Asger Blekinge-Rasmussen, ${global_project_prefix} Project Consortium

Field Summary
static int MAX_BYTES_OUT
          Maximum number of bytes to be collected from std out
static int MAX_WAIT_MILLIS
          The Maximum wait time
static int WAIT
          Time to wait
 
Constructor Summary
ProcessRunner()
          Constructor which initialises the process builder
ProcessRunner(List<String> commands)
          Constructor which takes the command list
 
Method Summary
 int getCode()
          Get process return code
 InputStream getErrInputStream()
          Get error stream of the process
 InputStream getStdInputStream()
          Get input stream of the process
 void run()
          Run the process
 void setCommandList(List<String> commands)
          Set the command list that will be passed to the process builder
 void setProcessDir(String processDirName)
          Initial dir of the process.
 void setProcessInputStream(InputStream processInputStream)
          Set process input stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_BYTES_OUT

public static final int MAX_BYTES_OUT
Maximum number of bytes to be collected from std out

See Also:
Constant Field Values

WAIT

public static final int WAIT
Time to wait

See Also:
Constant Field Values

MAX_WAIT_MILLIS

public static final int MAX_WAIT_MILLIS
The Maximum wait time

See Also:
Constant Field Values
Constructor Detail

ProcessRunner

public ProcessRunner()
Constructor which initialises the process builder


ProcessRunner

public ProcessRunner(List<String> commands)
Constructor which takes the command list

Parameters:
commands -
Method Detail

setCommandList

public void setCommandList(List<String> commands)
Set the command list that will be passed to the process builder

Parameters:
commands - Command list

setProcessInputStream

public void setProcessInputStream(InputStream processInputStream)
Set process input stream

Parameters:
processInputStream - Process input stream

getStdInputStream

public InputStream getStdInputStream()
Get input stream of the process

Returns:
Input stream

getErrInputStream

public InputStream getErrInputStream()
Get error stream of the process

Returns:
Error stream

getCode

public int getCode()
Get process return code

Returns:
Return code

run

public void run()
Run the process

Specified by:
run in interface Runnable

setProcessDir

public void setProcessDir(String processDirName)
Initial dir of the process.

Parameters:
processDirName - Name of initial dir


Copyright © 2013. All Rights Reserved.