@ThreadSafe
public class ScriptManager
extends java.lang.Object
ScriptEngine) via URI
(e.g., local file, classpath, URL).
N.B.: Scripts must be explicitly registered by calling manageScript(URI) in order to be evaluated.
N.B.: If a compilation or access error is encountered while reloading a previously compiled script, the latest compiled version is retained, until it can be replaced with a newer one.
| Constructor and Description |
|---|
ScriptManager(ScriptManagerProperties properties,
org.springframework.scheduling.TaskScheduler taskScheduler,
java.util.concurrent.ExecutorService executorService,
javax.script.ScriptEngineManager scriptEngineManager,
org.springframework.core.io.ResourceLoader resourceLoader,
io.micrometer.core.instrument.MeterRegistry meterRegistry)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
evaluateScript(java.net.URI scriptUri,
javax.script.Bindings bindings,
long timeout)
Evaluate a given script.
|
void |
manageScript(java.net.URI scriptUri)
Start managing the given script, loading it ASAP (asynchronously) and refreshing it periodically.
|
public ScriptManager(ScriptManagerProperties properties, org.springframework.scheduling.TaskScheduler taskScheduler, java.util.concurrent.ExecutorService executorService, javax.script.ScriptEngineManager scriptEngineManager, org.springframework.core.io.ResourceLoader resourceLoader, io.micrometer.core.instrument.MeterRegistry meterRegistry)
properties - propertiestaskScheduler - task schedulerexecutorService - executor servicescriptEngineManager - script engine managerresourceLoader - resource loadermeterRegistry - meter registrypublic void manageScript(java.net.URI scriptUri)
scriptUri - the script to load and manageprotected java.lang.Object evaluateScript(java.net.URI scriptUri,
javax.script.Bindings bindings,
long timeout)
throws ScriptNotConfiguredException,
ScriptExecutionException
scriptUri - the script URIbindings - the input parameter bindingstimeout - the timeout in millisecondsScriptNotConfiguredException - if the script is not loaded (due to invalid URI or compilation errors).ScriptExecutionException - if the script evaluation produces an error