org.hibernate.validator.util.scriptengine
Class ScriptEvaluator

java.lang.Object
  extended by org.hibernate.validator.util.scriptengine.ScriptEvaluator

public class ScriptEvaluator
extends java.lang.Object

A wrapper around JSR 223 ScriptEngines. This class is thread-safe.

Author:
Gunnar Morling, Kevin Pollet - SERLI - (kevin.pollet@serli.com)

Constructor Summary
ScriptEvaluator(javax.script.ScriptEngine engine)
          Creates a new script executor.
 
Method Summary
 java.lang.Object evaluate(java.lang.String script, java.lang.Object obj, java.lang.String objectAlias)
          Makes the given object available in then engine-scoped script context and executes the given script.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptEvaluator

public ScriptEvaluator(javax.script.ScriptEngine engine)
Creates a new script executor.

Parameters:
engine - The engine to be wrapped.
Method Detail

evaluate

public java.lang.Object evaluate(java.lang.String script,
                                 java.lang.Object obj,
                                 java.lang.String objectAlias)
                          throws javax.script.ScriptException
Makes the given object available in then engine-scoped script context and executes the given script. The execution of the script happens either synchronized or unsynchronized, depending on the engine's threading abilities.

Parameters:
script - The script to be executed.
obj - The object to be put into the context.
objectAlias - The name under which the given object shall be put into the context.
Returns:
The script's result.
Throws:
javax.script.ScriptException - In case of any errors during script execution.


Copyright © 2011 Oracle Corporation. All Rights Reserved.