MetaDone
|
Public Member Functions | |
JSEvaluator () | |
void | declareVariable (String name, Object value) |
void | clearVariables () |
void | reset () |
synchronized ScriptResult | evaluate (String script) |
final ProgLanguage | getLanguage () |
String | toString () |
Static Public Attributes | |
static final String | WRAP_COLLECTIONS = "wrap.collections" |
static final String | COMPILER_OPTIMIZATION_LEVEL = "compiler.optimization_level" |
Protected Member Functions | |
Object | getSecurityDomain () |
synchronized void | checkConfiguration () throws Exception |
void | initContext (Context cx) |
ScriptableObject | createScope (Context cx) |
void | updateScope (Context cx, Scriptable scope) |
synchronized Context | enterContext () |
synchronized void | exitContext () |
synchronized Scriptable | getScope () |
Protected Attributes | |
final Map< String, Object > | variables = new HashMap<String, Object>() |
Private Attributes | |
volatile Context | jsContext = null |
volatile Scriptable | jsScope = null |
volatile boolean | jsUpdateScope = true |
Static Private Attributes | |
static final Logger | logger = Logger.getLogger(JSEvaluator.class) |
A JavaScript evaluator based on Rhino.
metadone.metabusiness.script.js.JSEvaluator.JSEvaluator | ( | ) |
Initializes this evaluator.
References metadone.metabusiness.script.js.JSEvaluator.COMPILER_OPTIMIZATION_LEVEL, and metadone.metabusiness.script.ScriptEvaluator.Abstract.properties().
synchronized void metadone.metabusiness.script.js.JSEvaluator.checkConfiguration | ( | ) | throws Exception [protected] |
Checks the configuration before running a script.
Exception | when the class is not configured properly |
Referenced by metadone.metabusiness.script.js.JSEvaluator.evaluate().
void metadone.metabusiness.script.js.JSEvaluator.clearVariables | ( | ) |
Removes all the previously declared variables.
Implements metadone.metabusiness.script.ScriptEvaluator.
References metadone.metabusiness.script.js.JSEvaluator.jsUpdateScope, and metadone.metabusiness.script.js.JSEvaluator.variables.
Referenced by metadone.metabusiness.script.js.JSEvaluator.reset().
ScriptableObject metadone.metabusiness.script.js.JSEvaluator.createScope | ( | Context | cx | ) | [protected] |
Creates and updates a new scope.
cx | The context |
References metadone.metabusiness.script.js.JSEvaluator.updateScope().
Referenced by metadone.metabusiness.script.js.JSEvaluator.getScope().
void metadone.metabusiness.script.js.JSEvaluator.declareVariable | ( | String | name, |
Object | value | ||
) |
Declares a new variable called name and sets it to value.
updateContext() should be called afterwards.
name | The name of the variable |
value | The new value |
NullPointerException | when name is null |
Implements metadone.metabusiness.script.ScriptEvaluator.
References metadone.metabusiness.script.js.JSEvaluator.jsUpdateScope, and metadone.metabusiness.script.js.JSEvaluator.variables.
synchronized Context metadone.metabusiness.script.js.JSEvaluator.enterContext | ( | ) | [protected] |
Gets the context used by the evaluator.
References metadone.metabusiness.script.js.JSEvaluator.initContext(), and metadone.metabusiness.script.js.JSEvaluator.jsContext.
Referenced by metadone.metabusiness.script.js.JSEvaluator.evaluate().
synchronized ScriptResult metadone.metabusiness.script.js.JSEvaluator.evaluate | ( | String | script | ) |
Evaluates a script and returns a result.
script | The script to evaluate |
NullPointerException | when script is null |
Implements metadone.metabusiness.script.ScriptEvaluator.
References metadone.metabusiness.script.js.JSEvaluator.checkConfiguration(), metadone.metabusiness.script.js.JSEvaluator.enterContext(), metadone.metabusiness.script.js.JSEvaluator.exitContext(), metadone.metabusiness.script.js.JSEvaluator.getScope(), metadone.metabusiness.script.js.JSEvaluator.getSecurityDomain(), metadone.metabusiness.script.js.JSEvaluator.logger, and metadone.metabusiness.script.js.JSEvaluator.toString().
synchronized void metadone.metabusiness.script.js.JSEvaluator.exitContext | ( | ) | [protected] |
Exits the current context.
Referenced by metadone.metabusiness.script.js.JSEvaluator.evaluate().
final ProgLanguage metadone.metabusiness.script.js.JSEvaluator.getLanguage | ( | ) |
Gets the evaluated language.
Implements metadone.metabusiness.script.ScriptEvaluator.
synchronized Scriptable metadone.metabusiness.script.js.JSEvaluator.getScope | ( | ) | [protected] |
Gets the context used by the evaluator.
This method may be executed only after enterContext() has been executed.
References metadone.metabusiness.script.js.JSEvaluator.createScope(), metadone.metabusiness.script.js.JSEvaluator.jsContext, metadone.metabusiness.script.js.JSEvaluator.jsScope, metadone.metabusiness.script.js.JSEvaluator.jsUpdateScope, and metadone.metabusiness.script.js.JSEvaluator.updateScope().
Referenced by metadone.metabusiness.script.js.JSEvaluator.evaluate().
Object metadone.metabusiness.script.js.JSEvaluator.getSecurityDomain | ( | ) | [protected] |
Gets the security domain used to run the script.
null
Referenced by metadone.metabusiness.script.js.JSEvaluator.evaluate().
void metadone.metabusiness.script.js.JSEvaluator.initContext | ( | Context | cx | ) | [protected] |
Sets the required parameters for this context.
cx | The context to update |
References metadone.metabusiness.script.js.GenericJSWrapFactory.addExtensionFirst(), metadone.metabusiness.script.js.JSEvaluator.COMPILER_OPTIMIZATION_LEVEL, metadone.metabusiness.script.ScriptEvaluator.Abstract.getPropertyBoolean(), metadone.metabusiness.script.ScriptEvaluator.Abstract.properties(), and metadone.metabusiness.script.js.JSEvaluator.WRAP_COLLECTIONS.
Referenced by metadone.metabusiness.script.js.JSEvaluator.enterContext().
void metadone.metabusiness.script.js.JSEvaluator.reset | ( | ) |
Resets the script evaluator.
Implements metadone.metabusiness.script.ScriptEvaluator.
References metadone.metabusiness.script.js.JSEvaluator.clearVariables(), metadone.metabusiness.script.js.JSEvaluator.jsContext, metadone.metabusiness.script.js.JSEvaluator.jsScope, and metadone.metabusiness.script.js.JSEvaluator.jsUpdateScope.
String metadone.metabusiness.script.js.JSEvaluator.toString | ( | ) |
References metadone.metabusiness.script.js.JSEvaluator.jsContext.
Referenced by metadone.metabusiness.script.js.JSEvaluator.evaluate().
void metadone.metabusiness.script.js.JSEvaluator.updateScope | ( | Context | cx, |
Scriptable | scope | ||
) | [protected] |
Sets the required parameters for this scope.
cx | The context |
scope | The scope |
References metadone.metabusiness.script.js.JSEvaluator.variables.
Referenced by metadone.metabusiness.script.js.JSEvaluator.createScope(), and metadone.metabusiness.script.js.JSEvaluator.getScope().
final String metadone.metabusiness.script.js.JSEvaluator.COMPILER_OPTIMIZATION_LEVEL = "compiler.optimization_level" [static] |
volatile Context metadone.metabusiness.script.js.JSEvaluator.jsContext = null [private] |
volatile Scriptable metadone.metabusiness.script.js.JSEvaluator.jsScope = null [private] |
volatile boolean metadone.metabusiness.script.js.JSEvaluator.jsUpdateScope = true [private] |
final Logger metadone.metabusiness.script.js.JSEvaluator.logger = Logger.getLogger(JSEvaluator.class) [static, private] |
Referenced by metadone.metabusiness.script.js.JSEvaluator.evaluate().
final Map<String, Object> metadone.metabusiness.script.js.JSEvaluator.variables = new HashMap<String, Object>() [protected] |
final String metadone.metabusiness.script.js.JSEvaluator.WRAP_COLLECTIONS = "wrap.collections" [static] |
Referenced by metadone.metabusiness.script.js.JSEvaluator.initContext().