Package gda.jython
Interface ICommandRunner
- All Known Implementing Classes:
JythonServerFacade,MockJythonServerFacade
public interface ICommandRunner
Interface used by some classes to run a simple Jython command
Provided to ensure loose coupling between callers and command runner implementation
Runner Blocking Interruptible Script lock Throws exception evaluateCommand Yes No No No runCommand No Yes No No runScript No Yes Yes No runsource Yes Yes No No executeCommand Yes Yes No YesBlocking: This will not return until the command or script has finished running. If it takes a long time to run, it will hang the thread which calls this method, so this it must be called in a separate thread from the main GUI thread, else the GUI will seize up until the command has returned. Interruptible: Thread can be interrupted. If the command takes a long time to run, stopping a scan, script or doing a 'stop all' will interrupt the thread. Script lock: Acquire the script lock and run the script, or return BUSY without running the script, if the lock already has already been acquired. This allows script locked scripts to ensure only one will ever be running at once.
-
Method Summary
Modifier and TypeMethodDescriptionevaluateCommand(String command) Runs a single line Jython command through the interpreter and returns the result in the form of a string.voidexecuteCommand(String command) Executes the Jython command in a new thread.locateScript(String scriptToRun) Find a script with given name in the GDA's script project folders.voidrunCommand(String command) Executes the Jython command in a new thread.Runs the Jython script, and changes the ScriptStatus as is goes.Runs the jython command string, and changes the ScriptStatus as is goes.booleanSimilar torunCommand(java.lang.String), except that a boolean is returned if the command was complete or if additional lines of a multi-line command are required.
-
Method Details
-
runCommand
Executes the Jython command in a new thread.
Non-blocking, Interruptible, Not script locked.
SeeICommandRunnerfor the other options.- Parameters:
command- to run
-
executeCommand
Executes the Jython command in a new thread.
Blocking, Interruptible, Not script locked and throws ScriptExecutionException- Parameters:
command-- Throws:
ScriptExecutionException
-
evaluateCommand
Runs a single line Jython command through the interpreter and returns the result in the form of a string. Note: this method waits until the command has finished so it can return the result. If the command takes a long time it will hang the thread which calls this method. So this method must be called in a separate thread from the main GUI thread, else the GUI will seize up until the command given to this method has returned. For an example of the, see the gda.jython.JythonTerminal class.
Blocking, Not interruptible, Not script locked.
SeeICommandRunnerfor the other options.- Parameters:
command- to run- Returns:
- the string representation of the result
-
runScript
Runs the jython command string, and changes the ScriptStatus as is goes.
Non-blocking, Interruptible, Script locked.
SeeICommandRunnerfor the other options.- Parameters:
scriptContents- to run- Returns:
- status
-
runScript
Runs the Jython script, and changes the ScriptStatus as is goes.
Non-blocking, Interruptible, Script locked.
SeeICommandRunnerfor the other options.- Parameters:
script- to run- Returns:
- status
-
runsource
Similar torunCommand(java.lang.String), except that a boolean is returned if the command was complete or if additional lines of a multi-line command are required. Used only by the JythonTerminal to determine which prompt to display. Note: this method waits until the command has finished so it can return the result. If the command takes a long time it will hang the thread which calls this method. So this method must be called in a separate thread from the main GUI thread, else the GUI will seize up until the command given to this method has returned.
Blocking, Interruptible, Not script locked.
SeeICommandRunnerfor the other options.- Parameters:
command- to run- Returns:
- true if command was incomplete and more is required (eg "if True:"), false otherwise (including on error)
- See Also:
-
locateScript
Find a script with given name in the GDA's script project folders.- Parameters:
scriptToRun- The name of a Jython script file.- Returns:
- A path to the script in one of the project folders. The first file with matching name will be returned, or null if no file could be located.
-