org.objectledge.external
Class ProcessExecutor

java.lang.Object
  extended by org.objectledge.external.ProcessExecutor

public class ProcessExecutor
extends Object

Version:
$Id: ProcessExecutor.java,v 1.2 2006/03/28 18:02:38 zwierzem Exp $
Author:
RafaƂ Krzewski

Field Summary
static String DEFAULT_SHELL
          Default shell invocation format.
private  org.jcontainer.dna.Logger log
          The logger.
private  String[] shellTokens
          Shell invocation format.
 
Constructor Summary
ProcessExecutor(org.jcontainer.dna.Logger logger, org.jcontainer.dna.Configuration configuration)
          Creates a new ProcessExecutor instance.
ProcessExecutor(org.jcontainer.dna.Logger logger, String shell)
          Creates a new ProcessExecutor instance.
 
Method Summary
private  String concat(String[] args)
           
 ExecutionResult exec(boolean captureOutput, boolean captureError, String... args)
          Executes an external process.
 ExecutionResult exec(byte[] input, boolean captureOutput, boolean captureError, String... args)
          Executes an external process.
 ExecutionResult exec(String... args)
          Execute an external process.
 ExecutionResult exec(String input, boolean captureOutput, boolean captureError, String... args)
          Executes an external process.
private  byte[] read(File file)
           
private  void release(File file)
           
private  void write(File file, byte[] bytes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SHELL

public static final String DEFAULT_SHELL
Default shell invocation format.

See Also:
Constant Field Values

shellTokens

private final String[] shellTokens
Shell invocation format.


log

private final org.jcontainer.dna.Logger log
The logger.

Constructor Detail

ProcessExecutor

public ProcessExecutor(org.jcontainer.dna.Logger logger,
                       String shell)
Creates a new ProcessExecutor instance.

Parameters:
logger - the logger to use.
shell - the shell invocation format.

ProcessExecutor

public ProcessExecutor(org.jcontainer.dna.Logger logger,
                       org.jcontainer.dna.Configuration configuration)
Creates a new ProcessExecutor instance.

Parameters:
logger - the logger to use.
configuration - component configuration.
Method Detail

exec

public ExecutionResult exec(String... args)
                     throws IOException
Execute an external process.

No data is sent to the process input stream, output and error streams are not captured.

Parameters:
args - the script name and arguments.
Returns:
execution result.
Throws:
IOException - If the execution fails.

exec

public ExecutionResult exec(byte[] input,
                            boolean captureOutput,
                            boolean captureError,
                            String... args)
                     throws IOException
Executes an external process.

Parameters:
input - data to be passed to the process inpupt stream.
captureOutput - should process output stream be captured.
captureError - should process error stream be captured.
args - process executable name and arguments.
Returns:
execution result.
Throws:
IOException - If the execution fails.

exec

public ExecutionResult exec(String input,
                            boolean captureOutput,
                            boolean captureError,
                            String... args)
                     throws IOException
Executes an external process.

Parameters:
input - data to be passed to the process inpupt stream.
captureOutput - should process output stream be captured.
captureError - should process error stream be captured.
args - process executable name and arguments.
Returns:
execution result.
Throws:
IOException
IOException - If the execution fails.

exec

public ExecutionResult exec(boolean captureOutput,
                            boolean captureError,
                            String... args)
                     throws IOException
Executes an external process.

Parameters:
captureOutput - should process output stream be captured.
captureError - should process error stream be captured.
args - process executable name and arguments.
Returns:
execution result.
Throws:
IOException
IOException - If the execution fails.

read

private byte[] read(File file)
             throws IOException
Throws:
IOException

write

private void write(File file,
                   byte[] bytes)
            throws IOException
Throws:
IOException

release

private void release(File file)

concat

private String concat(String[] args)


Copyright © 2003-2006 objectledge.org. All Rights Reserved.