allow script engines to have several types
This commit is contained in:
parent
a127499e3c
commit
5a7c8fe2cb
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||
*/
|
||||
public interface ScriptEngineService {
|
||||
|
||||
String type();
|
||||
String[] types();
|
||||
|
||||
Object compile(String script);
|
||||
|
||||
|
|
|
@ -57,7 +57,9 @@ public class ScriptService extends AbstractComponent {
|
|||
|
||||
ImmutableMap.Builder<String, ScriptEngineService> builder = ImmutableMap.builder();
|
||||
for (ScriptEngineService scriptEngine : scriptEngines) {
|
||||
builder.put(scriptEngine.type(), scriptEngine);
|
||||
for (String type : scriptEngine.types()) {
|
||||
builder.put(type, scriptEngine);
|
||||
}
|
||||
}
|
||||
this.scriptEngines = builder.build();
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ public class MvelScriptEngineService extends AbstractComponent implements Script
|
|||
}
|
||||
}
|
||||
|
||||
@Override public String type() {
|
||||
return "mvel";
|
||||
@Override public String[] types() {
|
||||
return new String[]{"mvel"};
|
||||
}
|
||||
|
||||
@Override public Object compile(String script) {
|
||||
|
|
|
@ -46,8 +46,8 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
|
|||
this.loader = new GroovyClassLoader(settings.getClassLoader());
|
||||
}
|
||||
|
||||
@Override public String type() {
|
||||
return "groovy";
|
||||
@Override public String[] types() {
|
||||
return new String[]{"groovy"};
|
||||
}
|
||||
|
||||
@Override public Object compile(String script) {
|
||||
|
|
Loading…
Reference in New Issue