com.partnersoft.scripting
Class BeanShellScript

java.lang.Object
  extended by com.partnersoft.scripting.AbstractScript
      extended by com.partnersoft.scripting.BeanShellScript
All Implemented Interfaces:
Script, java.lang.Runnable

public class BeanShellScript
extends AbstractScript

A script in the BeanShell language.

Copyright 2005-2006 Partner Software, Inc.

Version:
$Id: BeanShellScript.java 1897 2009-05-15 14:21:31Z paul $
Author:
Paul Reavis

Constructor Summary
BeanShellScript(java.lang.String scriptText)
           
BeanShellScript(VfsFile file)
           
 
Method Summary
 java.lang.Object getVariable(java.lang.String variableName)
          Gets a single variable defined for the script.
 void include(java.lang.String includeFile)
          Include the named file, which must be available in the ScriptKeeper provided via setScriptLibs()
 void includeFile(java.lang.String includeFilePath)
          Include the given file by path.
 void includeFile(VfsFile includeFile)
          Include the given file.
protected  void reloadImp()
          Subclasses should implement this method to do any maintenance associated with changes in the source file.
protected  java.lang.Object runScriptImp(Naming<java.lang.Object> variables)
          Subclasses should implement this method with their actual script-running implementation.
 void setScriptLibs(ScriptKeeper scriptLibs)
          Set a ScriptKeeper holding the available script libraries.
 
Methods inherited from class com.partnersoft.scripting.AbstractScript
getFile, getName, getScriptLog, getThrown, getVariables, isModified, parse, run, runScript, runThreaded, setThrown, setVariable, setVariables, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeanShellScript

public BeanShellScript(VfsFile file)

BeanShellScript

public BeanShellScript(java.lang.String scriptText)
Method Detail

setScriptLibs

public void setScriptLibs(ScriptKeeper scriptLibs)
Set a ScriptKeeper holding the available script libraries.


include

public void include(java.lang.String includeFile)
             throws bsh.EvalError,
                    java.io.FileNotFoundException,
                    java.io.IOException
Include the named file, which must be available in the ScriptKeeper provided via setScriptLibs()

Throws:
bsh.EvalError
java.io.FileNotFoundException
java.io.IOException

includeFile

public void includeFile(VfsFile includeFile)
                 throws bsh.EvalError,
                        java.io.FileNotFoundException,
                        java.io.IOException
Include the given file.

Throws:
bsh.EvalError
java.io.FileNotFoundException
java.io.IOException

includeFile

public void includeFile(java.lang.String includeFilePath)
                 throws bsh.EvalError,
                        java.io.FileNotFoundException,
                        java.io.IOException
Include the given file by path.

Throws:
bsh.EvalError
java.io.FileNotFoundException
java.io.IOException

getVariable

public java.lang.Object getVariable(java.lang.String variableName)
Description copied from interface: Script
Gets a single variable defined for the script. After a script run, can be used to get a variable set within the script itself. Before the script run only provides values that were set using Script.setVariable(String, Object).

Specified by:
getVariable in interface Script
Overrides:
getVariable in class AbstractScript
Parameters:
variableName - name of the variable in the script
Returns:
value of the variable, or null if it's not defined

reloadImp

protected void reloadImp()
                  throws java.lang.Exception
Description copied from class: AbstractScript
Subclasses should implement this method to do any maintenance associated with changes in the source file. This method is called whenever the source file's modification timestamp changes. Use it to load, parse, compile, or whatever you do with the scripting language in question to get it ready to execute. Feel free to throw exceptions; these will be caught and handled appropriately (logging the error, providing the Throwable in getThrown(), etc.).

Specified by:
reloadImp in class AbstractScript
Throws:
java.lang.Exception

runScriptImp

protected java.lang.Object runScriptImp(Naming<java.lang.Object> variables)
                                 throws java.lang.Exception
Description copied from class: AbstractScript
Subclasses should implement this method with their actual script-running implementation. They should feel free to throw exceptions; these will be caught and handled appropriately (logging the error, providing the Throwable in getThrown(), etc.).

Specified by:
runScriptImp in class AbstractScript
Throws:
java.lang.Exception