org.ourgrid.common.executor
Class Win32Executor

java.lang.Object
  extended by org.ourgrid.common.executor.AbstractExecutor
      extended by org.ourgrid.common.executor.Win32Executor
All Implemented Interfaces:
java.io.Serializable, Executor

public class Win32Executor
extends AbstractExecutor

See Also:
Serialized Form

Field Summary
static java.lang.String flagCommand
           
static java.lang.String flagFile
           
static java.lang.String flagLocalDir
           
static java.lang.String flagMachine
           
static java.lang.String flagRemoteDir
           
static java.lang.String flagRMIPort
           
static java.lang.String flagTunnelPort
           
 
Constructor Summary
Win32Executor()
           
 
Method Summary
 void chmod(java.io.File file, java.lang.String mode)
          Changes the permissions for the indicated file.
static java.lang.String convert2WinStyle(java.lang.String inn)
          This method is responsible to convert some linux variables and separators styles to Windows' ones
protected  java.io.File createScript(java.lang.String command, java.lang.String dirName)
           
protected  java.io.File createScript(java.lang.String command, java.lang.String dirName, java.util.Map envVars)
           
 ExecutorHandle execute(java.lang.String dirName, java.lang.String command)
          Execute a command like a OS native script.
 ExecutorHandle execute(java.lang.String dirName, java.lang.String command, java.util.Map envVars)
          Execute a local command in a specific dirName, with the environment defined by envVars
protected  ExecutorHandle getNextHandle()
          This method manage the handles issued for each command execution
 ExecutorResult getResult(ExecutorHandle handle)
          Blocks until the command finishes and returns its result
protected  void includeInProcesses(ExecutorHandle handle, java.lang.Process process)
          Adds a process into the set of the ones which results were not collected yet.
 void kill(ExecutorHandle handle)
          Kills command that was issued via an execute method
 
Methods inherited from class org.ourgrid.common.executor.AbstractExecutor
catchOutput
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flagCommand

public static final java.lang.String flagCommand
See Also:
Constant Field Values

flagMachine

public static final java.lang.String flagMachine
See Also:
Constant Field Values

flagLocalDir

public static final java.lang.String flagLocalDir
See Also:
Constant Field Values

flagRemoteDir

public static final java.lang.String flagRemoteDir
See Also:
Constant Field Values

flagFile

public static final java.lang.String flagFile
See Also:
Constant Field Values

flagTunnelPort

public static final java.lang.String flagTunnelPort
See Also:
Constant Field Values

flagRMIPort

public static final java.lang.String flagRMIPort
See Also:
Constant Field Values
Constructor Detail

Win32Executor

public Win32Executor()
Method Detail

chmod

public void chmod(java.io.File file,
                  java.lang.String mode)
           throws ExecutorException
Description copied from interface: Executor
Changes the permissions for the indicated file. Permissions are described using the "rwx" Linux convention. The permissions are changed in a way that further access from this JVM will see the new permissions.

Parameters:
file - the File object
mode - the new permission in "rwx" format
Throws:
ExecutorException - error changing the permissions

execute

public ExecutorHandle execute(java.lang.String dirName,
                              java.lang.String command)
                       throws ExecutorException
Execute a command like a OS native script. This a method used by the Executor class in order to provide some facilities provided by shell. For example, wild cards expansion.

Parameters:
command - The command must be executed
dirName - The directory where the execution will be started.
Returns:
The result (stdout and stderr) of the command execution
Throws:
ExecutorException - If the execution could not be performed.

execute

public ExecutorHandle execute(java.lang.String dirName,
                              java.lang.String command,
                              java.util.Map envVars)
                       throws ExecutorException
Description copied from interface: Executor
Execute a local command in a specific dirName, with the environment defined by envVars

Parameters:
dirName - directory to execute the script
command - command to be executed
envVars - environment variables used by this command
Returns:
a handle that identifies this execution
Throws:
ExecutorException - when there is a problem in the execution.

kill

public void kill(ExecutorHandle handle)
Description copied from interface: Executor
Kills command that was issued via an execute method

Parameters:
handle - the command handle

getResult

public ExecutorResult getResult(ExecutorHandle handle)
                         throws ExecutorException
Description copied from interface: Executor
Blocks until the command finishes and returns its result

Parameters:
handle - the command handle
Returns:
ExecutorResult StdOut, StdErr and exitValue from kill command.
Throws:
ExecutorException - when there is a problem while obtaining the result of an execution.

createScript

protected java.io.File createScript(java.lang.String command,
                                    java.lang.String dirName,
                                    java.util.Map envVars)
                             throws ExecutorException
Throws:
ExecutorException

createScript

protected java.io.File createScript(java.lang.String command,
                                    java.lang.String dirName)
                             throws ExecutorException
Throws:
ExecutorException

convert2WinStyle

public static java.lang.String convert2WinStyle(java.lang.String inn)
This method is responsible to convert some linux variables and separators styles to Windows' ones

Parameters:
inn - String containing the text that should be processed and if necessary converted to windows style
Returns:
The string converted for windows' format

includeInProcesses

protected void includeInProcesses(ExecutorHandle handle,
                                  java.lang.Process process)
Adds a process into the set of the ones which results were not collected yet.

Parameters:
handle - The handle for the process
process - The process to be included at the group

getNextHandle

protected ExecutorHandle getNextHandle()
This method manage the handles issued for each command execution

Returns:
A handle to be used by the client to identify its execution