Support ScriptEngine#eval(String, Bindings) in ScriptTemplateView
Supporting ScriptEngine#eval(String, Bindings) when no render function
is specified allows to support use cases where script templates are
simply evaluating a script expression with an even more simplified
configuration.
This improvement also makes it possible to use script engines that
do not implement Invocable.
Issue: SPR-15115
@ -63,9 +65,23 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@@ -63,9 +65,23 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@ -83,7 +99,7 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@@ -83,7 +99,7 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@ -152,14 +168,15 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@@ -152,14 +168,15 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@ -112,7 +113,6 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@@ -112,7 +113,6 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
Assert.isInstanceOf(Invocable.class,engine,"ScriptEngine must implement Invocable");
this.engine=engine;
}
@ -225,7 +225,9 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@@ -225,7 +225,9 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
setEngine(createEngineFromName());
}
Assert.isTrue(this.renderFunction!=null,"The 'renderFunction' property must be defined.");
if(this.renderFunction!=null&&this.engine!=null){
Assert.isInstanceOf(Invocable.class,this.engine,"ScriptEngine must implement Invocable when 'renderFunction' is specified.");
}
}
protectedScriptEnginegetEngine(){
@ -297,8 +299,6 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@@ -297,8 +299,6 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@ -316,12 +316,18 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@@ -316,12 +316,18 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@ -65,9 +67,23 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@@ -65,9 +67,23 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@ -85,7 +101,7 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@@ -85,7 +101,7 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@ -155,13 +171,15 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@@ -155,13 +171,15 @@ public class ScriptTemplateConfigurer implements ScriptTemplateConfig {
@ -126,7 +127,6 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@@ -126,7 +127,6 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
Assert.isInstanceOf(Invocable.class,engine,"ScriptEngine must implement Invocable");
this.engine=engine;
}
@ -260,7 +260,9 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@@ -260,7 +260,9 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
setEngine(createEngineFromName());
}
Assert.isTrue(this.renderFunction!=null,"The 'renderFunction' property must be defined.");
if(this.renderFunction!=null&&this.engine!=null){
Assert.isInstanceOf(Invocable.class,this.engine,"ScriptEngine must implement Invocable when 'renderFunction' is specified.");
}
}
protectedScriptEnginegetEngine(){
@ -357,7 +359,6 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@@ -357,7 +359,6 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
try{
ScriptEngineengine=getEngine();
Invocableinvocable=(Invocable)engine;
Stringurl=getUrl();
Assert.state(url!=null,"'url' not set");
Stringtemplate=getTemplate(url);
@ -372,12 +373,18 @@ public class ScriptTemplateView extends AbstractUrlBasedView {
@@ -372,12 +373,18 @@ public class ScriptTemplateView extends AbstractUrlBasedView {