uk.ac.ncl.cs.instantsoap.python
Class PythonExecutor

java.lang.Object
  extended by uk.ac.ncl.cs.instantsoap.python.PythonExecutor

public class PythonExecutor
extends Object

Java code to execute Python scripts.

The Executor is responsible for handling the native Python processes, invoking them with the correct options, and marshaling and unmarshaling the XML for them.

Author:
Matthew Pocock

Constructor Summary
PythonExecutor()
           
 
Method Summary
 Map<String,String> execute(String module, String application, Map<String,String> inputs)
          Execute a particular entry point in a module.
 String getExecutePy()
          Get the python execution script name.
 File[] getExtraPythonPaths()
          Get all of the extra python paths that should be searched when scanning for modules.
 File getInstantPyLocation()
          Get the python driver directory.
 String getIntrospectPy()
          Get the name of the python introspection script.
 String getPythonShell()
          Get the python shell.
 File getWorkingDir()
          Get the working directory for native commands launched through this executor.
 Map<String,ScriptMetaData> introspectScript(String module)
          Introspect all of the instantsoap entry points in the named module.
 void setExecutePy(String executePy)
          Set the python execution script name.
 void setExtraPythonPaths(File[] extraPythonPaths)
          Set all of the extra python paths that should be searched when scanning for modules.
 void setInstantPyLocation(File instantPyLocation)
          Set the python driver directory.
 void setIntrospectPy(String introspectPy)
          Set the name of the python introspection script.
 void setPythonShell(String pythonShell)
          Set the python shell.
 void setWorkingDir(File workingDir)
          Set the working directory for native commands launched through this executor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PythonExecutor

public PythonExecutor()
Method Detail

getPythonShell

public String getPythonShell()
Get the python shell. This is the file location of the python binary.

Returns:
the python shell location

setPythonShell

public void setPythonShell(String pythonShell)
Set the python shell. This is the file location of the python binary.

Parameters:
pythonShell - the python shell location

getWorkingDir

public File getWorkingDir()
Get the working directory for native commands launched through this executor.

Returns:
the current working directory File

setWorkingDir

public void setWorkingDir(File workingDir)
Set the working directory for native commands launched through this executor.

Parameters:
workingDir - the new working directory File

getInstantPyLocation

public File getInstantPyLocation()
Get the python driver directory.

Returns:
a File giving the location of the python driver scripts

setInstantPyLocation

public void setInstantPyLocation(File instantPyLocation)
Set the python driver directory.

Parameters:
instantPyLocation - the File where the python driver is installed

getExtraPythonPaths

public File[] getExtraPythonPaths()
Get all of the extra python paths that should be searched when scanning for modules.

Returns:
the python paths as an array of Files

setExtraPythonPaths

public void setExtraPythonPaths(File[] extraPythonPaths)
Set all of the extra python paths that should be searched when scanning for modules.

Parameters:
extraPythonPaths - the python paths as an array of Files

getIntrospectPy

public String getIntrospectPy()
Get the name of the python introspection script. This is assumed to reside in the python driver directory.

Returns:
the python introspection script name

setIntrospectPy

public void setIntrospectPy(String introspectPy)
Set the name of the python introspection script.

Parameters:
introspectPy - the python introspection script name

getExecutePy

public String getExecutePy()
Get the python execution script name. This is assumed to reside in the python driver directory.

Returns:
the execution script name

setExecutePy

public void setExecutePy(String executePy)
Set the python execution script name. This is assumed to reside in the python driver directory.

Parameters:
executePy - the execution script name

introspectScript

public Map<String,ScriptMetaData> introspectScript(String module)
                                            throws JAXBException,
                                                   IOException
Introspect all of the instantsoap entry points in the named module.

Parameters:
module - the module to scan
Returns:
metadata indexed by entry point name
Throws:
JAXBException - if the XML messages could not be handled
IOException - if there where problems contacting the native process

execute

public Map<String,String> execute(String module,
                                  String application,
                                  Map<String,String> inputs)
                           throws IOException,
                                  JAXBException,
                                  TransformerException
Execute a particular entry point in a module.

Parameters:
module - the module to use
application - the named entrypoint in the module
inputs - the name/value inputs
Returns:
name/value pairs representing the result
Throws:
IOException - if there where problems communicating with the native process
JAXBException - if there where problems with the XML
TransformerException - if there where problems formatting the XML messages


Copyright © 2006-2008. All Rights Reserved.