Classes | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes

de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder Class Reference

List of all members.

Classes

interface  IConsumer
class  UnbufferedStreamConsumer

Public Member Functions

 ExtendedProcessBuilder (File executable)
 ExtendedProcessBuilder (File executable, String...params)
Map< String, String > getEnvironment ()
List< String > getParams ()
File getWorkingDirectory ()
void setParams (List< String > params)
void setParams (String...params)
void setWorkingDirectory (File directory)
Process startProcessAndConsumer (IConsumer consumer) throws IOException
Process startProcessAndConsumerUsingCygwin (IConsumer consumer) throws IOException

Static Public Member Functions

static String getExecutableExtension ()
static void main (String...args) throws IOException, InterruptedException
static void setExecutableFlagIfPossible (File file) throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException

Private Attributes

final File executable
List< String > params
final ProcessBuilder pb

Static Private Attributes

static int no

Detailed Description

Extended process builder to create and control external processes more comfortable. Java internal ProcessBuilder is final, so we have to delegate.

TODO: move this class to vts_lib_common when the API has become stable. TODO: implement setting process priority via JNI or command line. TODO: implement executable flag under Java 5.0.

Author:
shanno

Constructor & Destructor Documentation

de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.ExtendedProcessBuilder ( File  executable  ) 
de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.ExtendedProcessBuilder ( File  executable,
String...  params 
)

Member Function Documentation

Map<String, String> de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.getEnvironment (  ) 
static String de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.getExecutableExtension (  )  [static]

Returns the OS dependent executable extension or ".bin" under linux.

List<String> de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.getParams (  ) 
File de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.getWorkingDirectory (  ) 
static void de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.main ( String...  args  )  throws IOException, InterruptedException [static]

Sample code to demonstrate usage.

static void de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.setExecutableFlagIfPossible ( File  file  )  throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException [static]

If possible, sets the executable flag of a file.

Under Windows, there is no executable flag; nothing is done. Using Java 6.0 under Unix, the executable flag is set. When a older Java version is used, a NoSuchMethodException is thrown.

Parameters:
file 
void de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.setParams ( List< String >  params  ) 
void de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.setParams ( String...  params  ) 
void de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.setWorkingDirectory ( File  directory  ) 
Process de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.startProcessAndConsumer ( IConsumer  consumer  )  throws IOException

Sets the executable flag (if possible), combines stdout and stderr, starts the external process and starts the consumer process.

Parameters:
consumer The consumer to use or null for default stdout consumer.
Returns:
The created process
Process de.fraunhofer.isst.axbench.timing.tools.ExtendedProcessBuilder.startProcessAndConsumerUsingCygwin ( IConsumer  consumer  )  throws IOException

Copies the cygwin-dll from lib/cygwin1.dll_ to the working dir, executes and waits for finish and finally removes the cygwin dll. On non-windows environments, method invocation is redirected to startProcessAndConsumer(...).

TODO: untested yet


Member Data Documentation