org.apache.bsf.util

Class BSFEngineImpl

public abstract class BSFEngineImpl extends Object implements BSFEngine

This is a base implementation of the BSFEngine interface which engine implementations may choose to extend to get the basic methods of the interface implemented.

Author: Sanjiva Weerawarana Olivier Gruber (adding debugging support)

Field Summary
protected ClassLoaderclassLoader
protected StringclassPath
protected BSFDebugManagerImpldbgmgr
protected VectordeclaredBeans
protected Stringlang
protected BSFManagermgr
protected StringtempDir
Constructor Summary
BSFEngineImpl()
Get the debug manager in the constructor, not in initialize.
Method Summary
Objectapply(String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments)
Default impl of apply - calls eval ignorning parameters and returns the result.
voidcompileApply(String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments, CodeBuffer cb)
Default impl of compileApply - calls compileExpr ignorning parameters.
voidcompileExpr(String source, int lineNo, int columnNo, Object expr, CodeBuffer cb)
Default impl of compileExpr - generates code that'll create a new manager, evaluate the expression, and return the value.
voidcompileScript(String source, int lineNo, int columnNo, Object script, CodeBuffer cb)
Default impl of compileScript - generates code that'll create a new manager, and execute the script.
voiddeclareBean(BSFDeclaredBean bean)
voiddisconnectedDebuggerNotify()
Basic engines are not supporting breakpoints for the meaning and support is something that is language-specific.
voidexec(String source, int lineNo, int columnNo, Object script)
Default impl of execute - calls eval and ignores the result.
ObjectgetSpecificDebuggingInterface()
By default, an engine does not support debugging.
voidinitialize(BSFManager mgr, String lang, Vector declaredBeans)
initialize the engine; called right after construction by the manager.
voidplaceBreakpointAtLine(int brkptid, String docname, int lineno)
voidplaceBreakpointAtOffset(int brkptid, String docname, int offset)
voidpropertyChange(PropertyChangeEvent e)
Receive property change events from the manager and update my fields as needed.
voidremoveBreakpoint(String docname, int brkptid)
voidsetEntryExit(String docname, boolean on)
voidterminate()
voidundeclareBean(BSFDeclaredBean bean)

Field Detail

classLoader

protected ClassLoader classLoader

classPath

protected String classPath

dbgmgr

protected BSFDebugManagerImpl dbgmgr

declaredBeans

protected Vector declaredBeans

lang

protected String lang

mgr

protected BSFManager mgr

tempDir

protected String tempDir

Constructor Detail

BSFEngineImpl

public BSFEngineImpl()
Get the debug manager in the constructor, not in initialize. First, this is ok since the debug manager is not BSFManager dependent. Second, the debug manager needs to be known sooner than "initialize" for the JavaScript engine.

Method Detail

apply

public Object apply(String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments)
Default impl of apply - calls eval ignorning parameters and returns the result.

compileApply

public void compileApply(String source, int lineNo, int columnNo, Object funcBody, Vector paramNames, Vector arguments, CodeBuffer cb)
Default impl of compileApply - calls compileExpr ignorning parameters.

compileExpr

public void compileExpr(String source, int lineNo, int columnNo, Object expr, CodeBuffer cb)
Default impl of compileExpr - generates code that'll create a new manager, evaluate the expression, and return the value.

compileScript

public void compileScript(String source, int lineNo, int columnNo, Object script, CodeBuffer cb)
Default impl of compileScript - generates code that'll create a new manager, and execute the script.

declareBean

public void declareBean(BSFDeclaredBean bean)

disconnectedDebuggerNotify

public void disconnectedDebuggerNotify()
Basic engines are not supporting breakpoints for the meaning and support is something that is language-specific.

exec

public void exec(String source, int lineNo, int columnNo, Object script)
Default impl of execute - calls eval and ignores the result.

getSpecificDebuggingInterface

public Object getSpecificDebuggingInterface()
By default, an engine does not support debugging. Subclasses will need to redefine this method in order to provide debuggers with their language-specific interface for debugging.

initialize

public void initialize(BSFManager mgr, String lang, Vector declaredBeans)
initialize the engine; called right after construction by the manager. Declared beans are simply kept in a vector and that's it. Subclasses must do whatever they want with it.

placeBreakpointAtLine

public void placeBreakpointAtLine(int brkptid, String docname, int lineno)

placeBreakpointAtOffset

public void placeBreakpointAtOffset(int brkptid, String docname, int offset)

propertyChange

public void propertyChange(PropertyChangeEvent e)
Receive property change events from the manager and update my fields as needed.

Parameters: e PropertyChange event with the change data

removeBreakpoint

public void removeBreakpoint(String docname, int brkptid)

setEntryExit

public void setEntryExit(String docname, boolean on)

terminate

public void terminate()

undeclareBean

public void undeclareBean(BSFDeclaredBean bean)