use of eu.esdihumboldt.util.groovy.sandbox.GroovyService.ResultProcessor in project hale by halestudio.
the class GroovyScript method evaluate.
/**
* @see Script#evaluate(String, Iterable, ServiceProvider)
*/
@Override
public Object evaluate(String script, Iterable<PropertyValue> variables, ServiceProvider provider) throws ScriptException {
Binding binding = createGroovyBinding(variables, true);
GroovyService service = provider.getService(GroovyService.class);
Object result;
try {
result = service.evaluate(service.parseScript(script, binding), new ResultProcessor<Object>() {
@Override
public Object process(groovy.lang.Script script, Object returnValue) throws Exception {
return returnValue;
}
});
} catch (Exception e) {
throw new ScriptException(e);
} catch (Throwable t) {
throw new ScriptException(t.toString());
}
if (result == null) {
// XXX throw new NoResultException(); ? as cause for SE?
throw new ScriptException("no result");
}
return result;
}
Aggregations