Package ch.obermuhlner.scriptengine.java
Class JavaScriptEngine
java.lang.Object
ch.obermuhlner.scriptengine.java.JavaScriptEngine
- All Implemented Interfaces:
Compilable
,ScriptEngine
Script engine to compile and run a Java class on the fly.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ConstructorStrategy
private ScriptContext
private ClassLoader
private ExecutionStrategyFactory
private Isolation
private NameStrategy
Fields inherited from interface javax.script.ScriptEngine
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioneval
(Reader reader, ScriptContext context) eval
(String script, ScriptContext context) getBindings
(int scope) void
private String
readScript
(Reader reader) void
setBindings
(Bindings bindings, int scope) void
setConstructorStrategy
(ConstructorStrategy constructorStrategy) Sets the constructor strategy used to construct a Java instance of a class.void
setContext
(ScriptContext context) void
setExecutionClassLoader
(ClassLoader executionClassLoader) Sets theClassLoader
used to load and execute the class.void
setExecutionStrategyFactory
(ExecutionStrategyFactory executionStrategyFactory) Sets the factory for the execution strategy used to execute a method of a class instance.void
setIsolation
(Isolation isolation) Sets the isolation of the script.void
setNameStrategy
(NameStrategy nameStrategy) Sets the name strategy used to determine the Java class name from a script.
-
Field Details
-
nameStrategy
-
constructorStrategy
-
executionStrategyFactory
-
isolation
-
context
-
executionClassLoader
-
-
Constructor Details
-
JavaScriptEngine
public JavaScriptEngine()
-
-
Method Details
-
setNameStrategy
Sets the name strategy used to determine the Java class name from a script.- Parameters:
nameStrategy
- theNameStrategy
to use in this script engine
-
setConstructorStrategy
Sets the constructor strategy used to construct a Java instance of a class.- Parameters:
constructorStrategy
- theConstructorStrategy
to use in this script engine
-
setExecutionStrategyFactory
Sets the factory for the execution strategy used to execute a method of a class instance.- Parameters:
executionStrategyFactory
- theExecutionStrategyFactory
to use in this script engine
-
setExecutionClassLoader
Sets theClassLoader
used to load and execute the class.- Parameters:
executionClassLoader
- the executionClassLoader
-
setIsolation
Sets the isolation of the script.- Parameters:
isolation
- theIsolation
-
getContext
- Specified by:
getContext
in interfaceScriptEngine
-
setContext
- Specified by:
setContext
in interfaceScriptEngine
-
createBindings
- Specified by:
createBindings
in interfaceScriptEngine
-
getBindings
- Specified by:
getBindings
in interfaceScriptEngine
-
setBindings
- Specified by:
setBindings
in interfaceScriptEngine
-
put
- Specified by:
put
in interfaceScriptEngine
-
get
- Specified by:
get
in interfaceScriptEngine
-
eval
- Specified by:
eval
in interfaceScriptEngine
- Throws:
ScriptException
-
eval
- Specified by:
eval
in interfaceScriptEngine
- Throws:
ScriptException
-
eval
- Specified by:
eval
in interfaceScriptEngine
- Throws:
ScriptException
-
eval
- Specified by:
eval
in interfaceScriptEngine
- Throws:
ScriptException
-
eval
- Specified by:
eval
in interfaceScriptEngine
- Throws:
ScriptException
-
eval
- Specified by:
eval
in interfaceScriptEngine
- Throws:
ScriptException
-
compile
- Specified by:
compile
in interfaceCompilable
- Throws:
ScriptException
-
compile
- Specified by:
compile
in interfaceCompilable
- Throws:
ScriptException
-
getFactory
- Specified by:
getFactory
in interfaceScriptEngine
-
readScript
- Throws:
ScriptException
-