Top Description Fields Constructors Methods
org.hibernate.validator.spi.scripting

public Class ScriptEngineScriptEvaluator

extends Object
implements ScriptEvaluator
Class Inheritance
All Implemented Interfaces
org.hibernate.validator.spi.scripting.ScriptEvaluator
Annotations
@Incubating
Imports
java.lang.invoke.MethodHandles, java.util.Map, javax.script.ScriptEngine, .SimpleBindings, org.hibernate.validator.Incubating, org.hibernate.validator.internal.util.logging.Log, .LoggerFactory

A wrapper around JSR 223 ScriptEngines. This class is thread-safe.
Authors
Gunnar Morling, Kevin Pollet <[email protected]> (C) 2011 SERLI
Since
6.0.3

Field Summary

Modifier and TypeField and Description
private final ScriptEngine
private static final Log

Constructor Summary

AccessConstructor and Description
public
ScriptEngineScriptEvaluator(ScriptEngine
the engine to be wrapped
engine
)

Creates a new script executor.

Method Summary

Modifier and TypeMethod and Description
private Object
doEvaluate(String script, Map<String, Object> bindings)

private boolean

Returns:

true if the given engine is thread-safe, false otherwise.
engineAllowsParallelAccessFromMultipleThreads
()

Checks whether the given engine is thread-safe or not.

public Object

Returns:

the script's result
evaluate
(String
the script to be executed
script
,
Map<String, Object>
the bindings to be used
bindings
)

Implements org.hibernate.validator.spi.scripting.ScriptEvaluator.evaluate.

Executes the given script, using the given variable bindings.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

engineback to summary
private final ScriptEngine engine
LOGback to summary
private static final Log LOG

Constructor Detail

ScriptEngineScriptEvaluatorback to summary
public ScriptEngineScriptEvaluator(ScriptEngine engine)

Creates a new script executor.

Parameters
engine:ScriptEngine

the engine to be wrapped

Method Detail

doEvaluateback to summary
private Object doEvaluate(String script, Map<String, Object> bindings) throws ScriptEvaluationException
engineAllowsParallelAccessFromMultipleThreadsback to summary
private boolean engineAllowsParallelAccessFromMultipleThreads()

Checks whether the given engine is thread-safe or not.

Returns:boolean

true if the given engine is thread-safe, false otherwise.

evaluateback to summary
public Object evaluate(String script, Map<String, Object> bindings) throws ScriptEvaluationException

Implements org.hibernate.validator.spi.scripting.ScriptEvaluator.evaluate.

Executes the given script, using the given variable bindings. The execution of the script happens either synchronized or unsynchronized, depending on the engine's threading abilities.

Parameters
script:String

the script to be executed

bindings:Map<String, Object>

the bindings to be used

Returns:Object

the script's result

Annotations
@Override
Exceptions
ScriptEvaluationException:
in case an error occurred during the script evaluation