com.izforge.izpack.util
Class FileExecutor

java.lang.Object
  extended by com.izforge.izpack.util.FileExecutor

public class FileExecutor
extends java.lang.Object

Executes a bunch of files. This class is intended to do a system dependent installation postprocessing. Executable file can be any file installed with current package. After execution the file can be optionally removed. Before execution on Unix systems execution flag will be set on processed file.

Author:
Olexij Tkatchenko

Field Summary
private  java.util.Collection<ExecutableFile> files
          The files to execute.
private static java.lang.String JAR_FILE_SUFFIX
           
 
Constructor Summary
FileExecutor()
          Constructs a new executor.
FileExecutor(java.util.Collection<ExecutableFile> files)
          Constructs a new executor.
 
Method Summary
private  java.lang.String buildClassPath(java.lang.String targetFile)
          Transform classpath as specified in targetFile attribute into OS specific classpath.
 int executeCommand(java.lang.String[] params, java.lang.String[] output)
          Executed a system command and waits for completion.
 int executeFiles(int currentStage, AbstractUIHandler handler)
          Executes files specified at construction time.
static java.lang.String getExecOutput(java.lang.String[] aCommandLine)
          Gets the output of the given (console based) commandline
static java.lang.String getExecOutput(java.lang.String[] aCommandLine, boolean forceToGetStdOut)
          Executes the given Command and gets the result of StdOut, or if exec returns !
private  boolean stopThread(java.lang.Thread t, MonitorInputStream m)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAR_FILE_SUFFIX

private static final java.lang.String JAR_FILE_SUFFIX
See Also:
Constant Field Values

files

private java.util.Collection<ExecutableFile> files
The files to execute.

Constructor Detail

FileExecutor

public FileExecutor(java.util.Collection<ExecutableFile> files)
Constructs a new executor. The executable files specified must have pretranslated paths (variables expanded and file separator characters converted if necessary).

Parameters:
files - the executable files to process

FileExecutor

public FileExecutor()
Constructs a new executor.

Method Detail

stopThread

private boolean stopThread(java.lang.Thread t,
                           MonitorInputStream m)

getExecOutput

public static java.lang.String getExecOutput(java.lang.String[] aCommandLine)
Gets the output of the given (console based) commandline

Parameters:
aCommandLine - to execute
Returns:
the result of the command

getExecOutput

public static java.lang.String getExecOutput(java.lang.String[] aCommandLine,
                                             boolean forceToGetStdOut)
Executes the given Command and gets the result of StdOut, or if exec returns !=0: StdErr.

Parameters:
aCommandLine - aCommandLine to execute
forceToGetStdOut - if true returns stdout
Returns:
the result of the command stdout or stderr if exec returns !=0

executeCommand

public int executeCommand(java.lang.String[] params,
                          java.lang.String[] output)
Executed a system command and waits for completion.

Parameters:
params - system command as string array
output - contains output of the command index 0 = standard output index 1 = standard error
Returns:
exit status of process

executeFiles

public int executeFiles(int currentStage,
                        AbstractUIHandler handler)
Executes files specified at construction time.

Parameters:
currentStage - the stage of the installation
handler - The AbstractUIHandler to notify on errors.
Returns:
0 on success, else the exit status of the last failed command

buildClassPath

private java.lang.String buildClassPath(java.lang.String targetFile)
                                 throws java.lang.Exception
Transform classpath as specified in targetFile attribute into OS specific classpath. This method also resolves directories containing jar files. ';' and ':' are valid delimiters allowed in targetFile attribute.

Parameters:
targetFile -
Returns:
valid Java classpath
Throws:
java.lang.Exception