Is it possible to execute groovy code dynamically loaded in java application. For example there is a database table which contains small pieces of groovy code, like:
def test(${val_to_insert_from_java}){
if (${val_to_insert_from_java} > 10){
return true;
}
return false;
}
Where ${val_to_insert_from_java}
is a placeholder for some real value which gonna be inserted during execution of java code, like:
String groovyFuncSource = getFromDb();
groovyFuncSource.replace(${val_to_insert_from_java}, 9);
Object result = <evaluate somehow groovyFuncSource>;
Is there is a way to evaluate such piece of Groovy code? Or may be you advise me some other approach how to implemnt this.