org.apache.bsf.engines.activescript

Class ActiveScriptEngine

public class ActiveScriptEngine extends BSFEngineImpl implements JavaBeanAddEventListener

This is the interface to active scripting engines from the Bean Scripting Framework. This code uses John Ponzo's IBM Active Scripting Toolkit to tie in active scripting engines to BSF. This class implements Runnable to create a thread. This thread is to exclusively access the scripting engine. All methods from this class to the engines is proxied over to the engine thread for execution. Why? Because, MS engines are implemented to only be accessed from ONE thread.

Author: Sanjiva Weerawarana

Field Summary
protected Stringlang
Method Summary
voidaddEventListener(Object bean, String event, String filter, String script)
add an event listener
intbindMember(Object target, String name, short bindType)
Binds a method to an integer so it can be later referenced to invoke the method via callMethod.
Objectcall(Object object, String method, Object[] args)
Return an object from an extension.
ObjectcallMethod(Object bean, int methodID, Object[] args)
Invokes the method assocaited with methodID on the bean with parameters in the array args.
ObjectcreateBean(Object[] args)
createBean
static ThrowablecreateBSFException(int reason, String msg, Throwable t)
voiddeclareBean(BSFDeclaredBean bean)
Declare a bean after the engine has been started.
Objecteval(String source, int lineNo, int columnNo, Object oscript)
This is used by an application to evaluate a string containing some expression.
voidexec(String source, int lineNo, int columnNo, Object script)
This is used by an application to execute a string containing a script to execute.
protected voidfinalize()
voidinitialize(BSFManager mgr, String language, Vector declaredBeans)
protected booleanisCaseSensitive()
protected booleanisJScript()
protected booleanisPerlScript()
protected booleanisVBScript()
ObjectlookupBean(String name)
lookupBean
voidsetEvalRet(Object ret)
voidterminate()
voidundeclareBean(BSFDeclaredBean bean)
Undeclare a previously declared bean.

Field Detail

lang

protected String lang

Method Detail

addEventListener

public void addEventListener(Object bean, String event, String filter, String script)
add an event listener

bindMember

public final int bindMember(Object target, String name, short bindType)
Binds a method to an integer so it can be later referenced to invoke the method via callMethod.

call

public Object call(Object object, String method, Object[] args)
Return an object from an extension.

Parameters: method The name of the method to call. args an array of arguments to be passed to the extension, which may be either Vectors of Nodes, or Strings.

callMethod

public final Object callMethod(Object bean, int methodID, Object[] args)
Invokes the method assocaited with methodID on the bean with parameters in the array args.

createBean

public final Object createBean(Object[] args)
createBean

createBSFException

public static final Throwable createBSFException(int reason, String msg, Throwable t)

declareBean

public final void declareBean(BSFDeclaredBean bean)
Declare a bean after the engine has been started. Declared beans are beans that are named and which the engine must make available to the scripts it runs in the most first class way possible.

Parameters: bean the bean to declare

Throws: BSFException if the engine cannot do this operation

eval

public Object eval(String source, int lineNo, int columnNo, Object oscript)
This is used by an application to evaluate a string containing some expression. ActiveScript engines don't return anything .. so the return value is awlays null.

exec

public void exec(String source, int lineNo, int columnNo, Object script)
This is used by an application to execute a string containing a script to execute. ActiveScript engines don't return anything .. so the return value is awlays null.

finalize

protected void finalize()

initialize

public void initialize(BSFManager mgr, String language, Vector declaredBeans)

isCaseSensitive

protected final boolean isCaseSensitive()

isJScript

protected final boolean isJScript()

isPerlScript

protected final boolean isPerlScript()

isVBScript

protected final boolean isVBScript()

lookupBean

public final Object lookupBean(String name)
lookupBean

setEvalRet

public final void setEvalRet(Object ret)

terminate

public void terminate()

undeclareBean

public void undeclareBean(BSFDeclaredBean bean)
Undeclare a previously declared bean.

Parameters: bean the bean to undeclare

Throws: BSFException if the engine cannot do this operation