Skip to content

Commit

Permalink
HV-1463 Inject all binding variables into the Spring context
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Oct 18, 2017
1 parent ce1407a commit 697c9d9
Showing 1 changed file with 4 additions and 0 deletions.
Expand Up @@ -4,6 +4,7 @@
//end::include[]

import java.util.Map;
import java.util.Map.Entry;

import org.hibernate.validator.spi.scripting.AbstractCachingScriptEvaluatorFactory;
import org.hibernate.validator.spi.scripting.ScriptEvaluationException;
Expand Down Expand Up @@ -37,6 +38,9 @@ public Object evaluate(String script, Map<String, Object> bindings) throws Scrip
try {
Expression expression = expressionParser.parseExpression( script );
EvaluationContext context = new StandardEvaluationContext( bindings.values().iterator().next() );
for ( Entry<String, Object> binding : bindings.entrySet() ) {
context.setVariable( binding.getKey(), binding.getValue() );
}
return expression.getValue( context );
}
catch (ParseException | EvaluationException e) {
Expand Down

0 comments on commit 697c9d9

Please sign in to comment.