allow script engines to have several types

This commit is contained in:
kimchy 2010-10-02 21:18:01 +02:00
parent a127499e3c
commit 5a7c8fe2cb
4 changed files with 8 additions and 6 deletions

View File

@ -26,7 +26,7 @@ import java.util.Map;
*/
public interface ScriptEngineService {
String type();
String[] types();
Object compile(String script);

View File

@ -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();
}

View File

@ -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) {

View File

@ -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) {