From 5a7c8fe2cb635318fdeb2f04981b4a4f781810bb Mon Sep 17 00:00:00 2001 From: kimchy Date: Sat, 2 Oct 2010 21:18:01 +0200 Subject: [PATCH] allow script engines to have several types --- .../java/org/elasticsearch/script/ScriptEngineService.java | 2 +- .../src/main/java/org/elasticsearch/script/ScriptService.java | 4 +++- .../elasticsearch/script/mvel/MvelScriptEngineService.java | 4 ++-- .../script/groovy/GroovyScriptEngineService.java | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/script/ScriptEngineService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/script/ScriptEngineService.java index a4c852a3b4f..6c2cf33d309 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/script/ScriptEngineService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/script/ScriptEngineService.java @@ -26,7 +26,7 @@ import java.util.Map; */ public interface ScriptEngineService { - String type(); + String[] types(); Object compile(String script); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/script/ScriptService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/script/ScriptService.java index 64246410f61..964089a0115 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/script/ScriptService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/script/ScriptService.java @@ -57,7 +57,9 @@ public class ScriptService extends AbstractComponent { ImmutableMap.Builder 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(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java index bcfc90f7eaa..a9f6cc69f67 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/script/mvel/MvelScriptEngineService.java @@ -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) { diff --git a/plugins/lang/groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java b/plugins/lang/groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java index 7bf9663ebbb..5e6e19a2d16 100644 --- a/plugins/lang/groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java +++ b/plugins/lang/groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java @@ -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) {