use of groovy.lang.GroovyShell in project bamboobsc by billchen198318.
the class ScriptExpressionUtils method executeGroovy.
private static void executeGroovy(String scriptExpression, Map<String, Object> results, Map<String, Object> parameters) throws Exception {
//GroovyShell groovyShell = new GroovyShell(groovyCompilerConfig);
GroovyShell groovyShell = buildGroovyShell(false);
Binding binding = groovyShell.getContext();
if (parameters != null) {
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
//groovyShell.setProperty(entry.getKey(), entry.getValue());
binding.setVariable(entry.getKey(), entry.getValue());
}
}
groovyShell.evaluate(scriptExpression);
if (results != null) {
for (Map.Entry<String, Object> entry : results.entrySet()) {
//entry.setValue( groovyShell.getVariable(entry.getKey()) );
entry.setValue(binding.getVariable(entry.getKey()));
}
}
}
Aggregations