Package ch.obermuhlner.scriptengine.java
Class JavaCompiledScript
- java.lang.Object
-
- javax.script.CompiledScript
-
- ch.obermuhlner.scriptengine.java.JavaCompiledScript
-
public class JavaCompiledScript extends javax.script.CompiledScript
The compiled Java script created by aJavaScriptEngine
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<?>
compiledClass
private java.lang.Object
compiledInstance
private JavaScriptEngine
engine
private ExecutionStrategy
executionStrategy
-
Constructor Summary
Constructors Constructor Description JavaCompiledScript(JavaScriptEngine engine, java.lang.Class<?> compiledClass, java.lang.Object compiledInstance, ExecutionStrategy executionStrategy)
Construct aJavaCompiledScript
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Object
eval(javax.script.ScriptContext context)
java.lang.Class<?>
getCompiledClass()
Returns the compiledClass
.java.lang.Object
getCompiledInstance()
Returns the instance of the compiledClass
.javax.script.ScriptEngine
getEngine()
java.lang.Object
getInstance()
Deprecated.in release 1.1.0 this method was deprecated, usegetCompiledInstance()
instead.java.lang.Class<?>
getInstanceClass()
Deprecated.in release 1.1.0 this method was deprecated, usegetCompiledClass()
instead.private java.util.Map<java.lang.String,java.lang.Object>
mergeBindings(javax.script.Bindings... bindingsToMerge)
private void
pullVariables(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings)
private void
pushVariables(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings)
private void
setBindingsValue(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings, java.lang.String name, java.lang.Object value)
void
setExecutionStrategy(ExecutionStrategy executionStrategy)
Sets theExecutionStrategy
to be used when evaluating the compiled class instance.
-
-
-
Field Detail
-
engine
private final JavaScriptEngine engine
-
compiledClass
private final java.lang.Class<?> compiledClass
-
compiledInstance
private final java.lang.Object compiledInstance
-
executionStrategy
private ExecutionStrategy executionStrategy
-
-
Constructor Detail
-
JavaCompiledScript
JavaCompiledScript(JavaScriptEngine engine, java.lang.Class<?> compiledClass, java.lang.Object compiledInstance, ExecutionStrategy executionStrategy)
Construct aJavaCompiledScript
.- Parameters:
engine
- theJavaScriptEngine
that compiled this scriptcompiledClass
- the compiledClass
compiledInstance
- the instance of the compiledClass
ornull
if no instance was created and only static methods will be called by the theExecutionStrategy
.executionStrategy
- theExecutionStrategy
-
-
Method Detail
-
getCompiledClass
public java.lang.Class<?> getCompiledClass()
Returns the compiledClass
.- Returns:
- the compiled
Class
.
-
getCompiledInstance
public java.lang.Object getCompiledInstance()
Returns the instance of the compiledClass
.- Returns:
- the instance of the compiled
Class
ornull
if no instance was created and only static methods will be called by the theExecutionStrategy
.
-
getInstanceClass
@Deprecated public java.lang.Class<?> getInstanceClass()
Deprecated.in release 1.1.0 this method was deprecated, usegetCompiledClass()
instead.Returns the compiledClass
.- Returns:
- the compiled
Class
.
-
getInstance
@Deprecated public java.lang.Object getInstance()
Deprecated.in release 1.1.0 this method was deprecated, usegetCompiledInstance()
instead.Returns the instance of the compiledClass
.- Returns:
- the instance of the compiled
Class
ornull
if no instance was created and only static methods will be called by the theExecutionStrategy
.
-
setExecutionStrategy
public void setExecutionStrategy(ExecutionStrategy executionStrategy)
Sets theExecutionStrategy
to be used when evaluating the compiled class instance.- Parameters:
executionStrategy
- theExecutionStrategy
-
getEngine
public javax.script.ScriptEngine getEngine()
- Specified by:
getEngine
in classjavax.script.CompiledScript
-
eval
public java.lang.Object eval(javax.script.ScriptContext context) throws javax.script.ScriptException
- Specified by:
eval
in classjavax.script.CompiledScript
- Throws:
javax.script.ScriptException
-
pushVariables
private void pushVariables(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings) throws javax.script.ScriptException
- Throws:
javax.script.ScriptException
-
pullVariables
private void pullVariables(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings) throws javax.script.ScriptException
- Throws:
javax.script.ScriptException
-
setBindingsValue
private void setBindingsValue(javax.script.Bindings globalBindings, javax.script.Bindings engineBindings, java.lang.String name, java.lang.Object value)
-
mergeBindings
private java.util.Map<java.lang.String,java.lang.Object> mergeBindings(javax.script.Bindings... bindingsToMerge)
-
-