|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.script.ScriptEngine
public class ScriptEngine
This is the script engine wrapper used by TDI components.
Constructor Summary | |
---|---|
ScriptEngine(java.lang.String scriptlang)
Constructor |
|
ScriptEngine(java.lang.String scriptlang,
RSInterface server)
Constructor for the ScriptEngine object. |
|
ScriptEngine(java.lang.String scriptlang,
RSInterface server,
boolean debug)
|
Method Summary | |
---|---|
void |
addDebugListener(ScriptEngineOptions.TDIDebugListener listener)
Adds a listener to the list of debug callbacks. |
java.lang.Object |
call(java.lang.String function,
java.lang.Object[] param)
Calls a script function with given parameters. |
java.lang.Object |
call(java.lang.String function,
java.lang.Object[] param,
boolean ignoreMissing)
Calls a script function with given parameters. |
void |
clear()
Remove all declared non-static beans from the engine and local cache. |
void |
clearAll()
Remove all statically declared beans from the engine. |
void |
debug(java.lang.String msg)
NOOP |
void |
declareBean(java.lang.String name,
java.lang.Object obj)
Declares a "transient" script variable |
void |
declareBean(java.lang.String name,
java.lang.Object obj,
java.lang.Class<?> cls)
Declares a "transient" script variable |
void |
declareStaticBean(java.lang.String name,
java.lang.Object obj)
Declares a "static" script variable that stays in the engine until undeclared. |
void |
declareStaticBean(java.lang.String name,
java.lang.Object obj,
java.lang.Class<?> cls)
Declares a "static" script variable that stays in the engine until undeclared. |
void |
declareTaskBean()
Declares the "task" bean in the engine (the AssemblyLine). |
void |
declareTaskBean(java.lang.Object context)
Declares the "task" bean in the engine (the AssemblyLine). |
void |
declareUserFunctions()
Declare the standard java objects and user defined java objects as global variables in the engine. |
void |
dumpJSEngine()
Dumps the IBM JavaScript engine's variables and assignments (nice for debugging). |
java.lang.Object |
eval(java.lang.String expression)
Evaluates a script expression. |
void |
exec(java.lang.Object script)
Execute script |
void |
exec(java.lang.Object script,
java.lang.String name)
Execute script |
com.ibm.jscript.JSExpression |
getCompiledExpression(java.lang.String source)
Returns a previously compiled expression |
boolean |
getDebug()
Returns current status of the debugMode flag. |
ScriptExitCode |
getExitCode()
Gets the exitCode attribute of the ScriptEngine object |
com.ibm.jscript.JSInterpreter |
getJsengine()
Returns the IBMJS interpreter. |
ScriptEngineOptions |
getJSOptions()
Returns the ScriptEngineOptions object used by the script engine. |
java.lang.String |
getLanguage()
Gets the language attribute of the ScriptEngine object |
java.lang.String |
getScriptPrefix()
Returns the magic prefix used to signal the beginning of a script (not used internally by ScriptEngine). |
void |
includeAllScripts(MetamergeConfig mc)
Include all scripts from the script library where auto-include is true. |
void |
includeScript(java.lang.String files)
Includes a script from an external location (either file or URL) |
void |
includeScript(java.lang.String scriptName,
java.lang.String files)
Includes a script from an external location (either file or URL) |
void |
interpret(java.lang.String script)
Calls the jsengine.interpret(script). |
com.ibm.jscript.IValue |
interpret(java.lang.String map,
boolean registerFunctions)
Calls the jsengine.interpret(exp), and unwraps some Exceptions. |
boolean |
isFunctionDefined(java.lang.String functionName)
Returns true if a specific function exists in the script engine. |
com.ibm.jscript.InterpretException |
lastException(java.lang.Exception cause)
Return the last InterpretException, to supply line number for easier error detection. |
void |
loadScript(RSInterface parent,
java.lang.String contextName,
java.lang.String name,
boolean forceInclude)
This method includes a script in the current script engine context. |
void |
loadScript(java.lang.String contextName,
ScriptConfig map,
boolean forceInclude)
This method includes a script in the current script engine context. |
void |
popStackFrame()
Restores script engine bean references from a previously saved stack (pushStackFrame()) |
void |
pushStackFrame()
Preserves all declared beans in a stack (see popStackFrame) |
void |
removeDebugListener(ScriptEngineOptions.TDIDebugListener listener)
Removes the specified listener from the list of debug callbacks. |
void |
terminate()
Release resources |
void |
undeclareBean(java.lang.String name)
Removes the named script variable from the engine. |
void |
undeclareStaticBean(java.lang.String name)
Removes the named script variable from the engine. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ScriptEngine(java.lang.String scriptlang) throws java.lang.Exception
scriptlang
- Script language to use (ignored, always javascript)
java.lang.Exception
- Scriptpublic ScriptEngine(java.lang.String scriptlang, RSInterface server) throws java.lang.Exception
scriptlang
- Script language to use (ignored, always javascript)server
- Hosting TDI config instance
java.lang.Exception
public ScriptEngine(java.lang.String scriptlang, RSInterface server, boolean debug) throws java.lang.Exception
java.lang.Exception
Method Detail |
---|
public void declareUserFunctions() throws java.lang.Exception
java.lang.Exception
public java.lang.String getLanguage()
public ScriptExitCode getExitCode()
public void declareTaskBean() throws java.lang.Exception
java.lang.Exception
public void declareTaskBean(java.lang.Object context) throws java.lang.Exception
context
-
java.lang.Exception
public void declareStaticBean(java.lang.String name, java.lang.Object obj) throws java.lang.Exception
name
- The script name (as used in the script)obj
- The java object name refers to
java.lang.Exception
public void declareStaticBean(java.lang.String name, java.lang.Object obj, java.lang.Class<?> cls) throws java.lang.Exception
name
- The script name (as used in the script)obj
- The java object name refers tocls
- The class type of the object, ignored
java.lang.Exception
public void undeclareStaticBean(java.lang.String name) throws java.lang.Exception
name
- The script name (as used in the script)
java.lang.Exception
public void declareBean(java.lang.String name, java.lang.Object obj) throws java.lang.Exception
name
- The script name (as used in the script)obj
- The java object that name refers to.
java.lang.Exception
public void declareBean(java.lang.String name, java.lang.Object obj, java.lang.Class<?> cls) throws java.lang.Exception
name
- The script name (as used in the script)obj
- The java object that name refers to.cls
- obj's class, ignored
java.lang.Exception
public void undeclareBean(java.lang.String name)
name
- The script name (as used in the script)public void pushStackFrame()
public void popStackFrame()
public java.lang.Object eval(java.lang.String expression) throws java.lang.Exception
expression
- Script expression
java.lang.Exception
public java.lang.Object call(java.lang.String function, java.lang.Object[] param) throws java.lang.Exception
function
- Name of the functionparam
- Array of positional parameters
java.lang.Exception
- If any error occurspublic java.lang.Object call(java.lang.String function, java.lang.Object[] param, boolean ignoreMissing) throws java.lang.Exception
function
- Name of the functionparam
- Array of positional parametersignoreMissing
- If true, return null if function is missing. If false, throw
an Exception if function is missing.
java.lang.Exception
- If any error occurspublic void exec(java.lang.Object script) throws java.lang.Exception
script
- The script to execute
java.lang.Exception
public void exec(java.lang.Object script, java.lang.String name) throws java.lang.Exception
script
- The script to executename
- Name context (used in error messages etc)
java.lang.Exception
public void clear()
public void clearAll()
public void terminate()
public void dumpJSEngine()
public java.lang.String getScriptPrefix()
public void loadScript(RSInterface parent, java.lang.String contextName, java.lang.String name, boolean forceInclude) throws java.lang.Exception
parent
- The RSInterface to get the configuration fromcontextName
- A name identifying the contextname
- The script library nameforceInclude
- Force inclusion of the script (in case autoinclude is false)
java.lang.Exception
public void loadScript(java.lang.String contextName, ScriptConfig map, boolean forceInclude) throws java.lang.Exception
contextName
- A name identifying the contextmap
- The ScriptConfig objectforceInclude
- Force inclusion of the script (in case autoinclude is false)
java.lang.Exception
public void includeScript(java.lang.String files) throws java.lang.Exception
files
- CRLF separated list of files/URLs
java.lang.Exception
public void includeScript(java.lang.String scriptName, java.lang.String files) throws java.lang.Exception
scriptName
- Name of the scriptfiles
- CRLF separated list of files/URLs
java.lang.Exception
public void includeAllScripts(MetamergeConfig mc) throws java.lang.Exception
mc
- MetamergeConfig object from where scripts are included
java.lang.Exception
public void debug(java.lang.String msg)
msg
- public boolean getDebug()
public com.ibm.jscript.JSExpression getCompiledExpression(java.lang.String source) throws java.lang.Exception
source
- The script source
java.lang.Exception
public void interpret(java.lang.String script) throws java.lang.Exception
script
- The script
java.lang.Exception
public com.ibm.jscript.IValue interpret(java.lang.String map, boolean registerFunctions) throws java.lang.Exception
map
- The string expression to interpret
java.lang.Exception
- The Exception thrown by the interpret method, but
"com.ibm.di.*" Exceptions are unwrappedpublic com.ibm.jscript.InterpretException lastException(java.lang.Exception cause)
cause
- The Exception that contains the cause of the last Exception.
public com.ibm.jscript.JSInterpreter getJsengine()
public boolean isFunctionDefined(java.lang.String functionName)
functionName
- The function name
public void addDebugListener(ScriptEngineOptions.TDIDebugListener listener)
listener
- The callback objectpublic void removeDebugListener(ScriptEngineOptions.TDIDebugListener listener)
listener
- The callback objectpublic ScriptEngineOptions getJSOptions()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |