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 ConstructorStrategyprivate ScriptContextprivate ClassLoaderprivate ExecutionStrategyFactoryprivate Isolationprivate NameStrategyFields 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) voidprivate StringreadScript(Reader reader) voidsetBindings(Bindings bindings, int scope) voidsetConstructorStrategy(ConstructorStrategy constructorStrategy) Sets the constructor strategy used to construct a Java instance of a class.voidsetContext(ScriptContext context) voidsetExecutionClassLoader(ClassLoader executionClassLoader) Sets theClassLoaderused to load and execute the class.voidsetExecutionStrategyFactory(ExecutionStrategyFactory executionStrategyFactory) Sets the factory for the execution strategy used to execute a method of a class instance.voidsetIsolation(Isolation isolation) Sets the isolation of the script.voidsetNameStrategy(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- theNameStrategyto use in this script engine
-
setConstructorStrategy
Sets the constructor strategy used to construct a Java instance of a class.- Parameters:
constructorStrategy- theConstructorStrategyto use in this script engine
-
setExecutionStrategyFactory
Sets the factory for the execution strategy used to execute a method of a class instance.- Parameters:
executionStrategyFactory- theExecutionStrategyFactoryto use in this script engine
-
setExecutionClassLoader
Sets theClassLoaderused to load and execute the class.- Parameters:
executionClassLoader- the executionClassLoader
-
setIsolation
Sets the isolation of the script.- Parameters:
isolation- theIsolation
-
getContext
- Specified by:
getContextin interfaceScriptEngine
-
setContext
- Specified by:
setContextin interfaceScriptEngine
-
createBindings
- Specified by:
createBindingsin interfaceScriptEngine
-
getBindings
- Specified by:
getBindingsin interfaceScriptEngine
-
setBindings
- Specified by:
setBindingsin interfaceScriptEngine
-
put
- Specified by:
putin interfaceScriptEngine
-
get
- Specified by:
getin interfaceScriptEngine
-
eval
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
eval
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
eval
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
eval
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
eval
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
eval
- Specified by:
evalin interfaceScriptEngine- Throws:
ScriptException
-
compile
- Specified by:
compilein interfaceCompilable- Throws:
ScriptException
-
compile
- Specified by:
compilein interfaceCompilable- Throws:
ScriptException
-
getFactory
- Specified by:
getFactoryin interfaceScriptEngine
-
readScript
- Throws:
ScriptException
-