From d9aebf49065db9501e78f1a4323168536ff89999 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 8 Apr 2015 12:12:15 +0200 Subject: [PATCH] Scripting: remove deprecated methods from ScriptService Removed the following methods from `ScriptService`, which don't require the `ScriptContext` argument: ``` public CompiledScript compile(String lang, String script, ScriptType scriptType) public ExecutableScript executable(String lang, String script, ScriptType scriptType, Map vars) public SearchScript search(SearchLookup lookup, String lang, String script, ScriptType scriptType, @Nullable Map vars) ``` Also removed the ScriptContext.Standard.GENERIC_PLUGIN enum value, as it was used only for backwards compatibility. Plugins that make use of scripts should declare their own script contexts through `ScriptModule#registerScriptContext` and use them when compiling/executing scripts. Closes #10476 --- docs/reference/migration/migrate_2_0.asciidoc | 6 ++++ .../elasticsearch/script/ScriptContext.java | 9 +---- .../elasticsearch/script/ScriptService.java | 36 ------------------- 3 files changed, 7 insertions(+), 44 deletions(-) diff --git a/docs/reference/migration/migrate_2_0.asciidoc b/docs/reference/migration/migrate_2_0.asciidoc index 9ad8988fdd6..72272d20697 100644 --- a/docs/reference/migration/migrate_2_0.asciidoc +++ b/docs/reference/migration/migrate_2_0.asciidoc @@ -344,6 +344,12 @@ Deprecated script parameters `id`, `file`, and `scriptField` have been removed from all scriptable APIs. `script_id`, `script_file` and `script` should be used in their place. +=== Plugins making use of scripts + +Plugins that make use of scripts must register their own script context through +`ScriptModule`. Script contexts can be used as part of fine-grained settings to +enable/disable scripts selectively. + === Thrift and memcached transport The thrift and memcached transport plugins are no longer supported. Instead, use diff --git a/src/main/java/org/elasticsearch/script/ScriptContext.java b/src/main/java/org/elasticsearch/script/ScriptContext.java index 1993086ddb5..18224e81483 100644 --- a/src/main/java/org/elasticsearch/script/ScriptContext.java +++ b/src/main/java/org/elasticsearch/script/ScriptContext.java @@ -38,14 +38,7 @@ public interface ScriptContext { */ enum Standard implements ScriptContext { - AGGS("aggs"), MAPPING("mapping"), SEARCH("search"), UPDATE("update"), - /** - * Generic custom operation exposed via plugin - * - * @deprecated create a new {@link org.elasticsearch.script.ScriptContext.Plugin} instance instead - */ - @Deprecated - GENERIC_PLUGIN("plugin"); + AGGS("aggs"), MAPPING("mapping"), SEARCH("search"), UPDATE("update"); private final String key; diff --git a/src/main/java/org/elasticsearch/script/ScriptService.java b/src/main/java/org/elasticsearch/script/ScriptService.java index b615c8cb7d2..d2c848c4009 100644 --- a/src/main/java/org/elasticsearch/script/ScriptService.java +++ b/src/main/java/org/elasticsearch/script/ScriptService.java @@ -214,18 +214,6 @@ public class ScriptService extends AbstractComponent implements Closeable { return scriptEngineService; } - /** - * Checks if a script can be executed and compiles it if needed, or returns the previously compiled and cached script. - * Doesn't require to specify a script context in order to maintain backwards compatibility, internally uses - * the {@link org.elasticsearch.script.ScriptContext.Standard#GENERIC_PLUGIN} default context, assuming that it can only be called from plugins. - * - * @deprecated use the method variant that accepts the {@link ScriptContext} argument too: {@link #compile(String, String, ScriptType, ScriptContext)} - */ - @Deprecated - public CompiledScript compile(String lang, String script, ScriptType scriptType) { - return compile(lang, script, scriptType, ScriptContext.Standard.GENERIC_PLUGIN); - } - /** * Checks if a script can be executed and compiles it if needed, or returns the previously compiled and cached script. */ @@ -394,18 +382,6 @@ public class ScriptService extends AbstractComponent implements Closeable { } } - /** - * Compiles (or retrieves from cache) and executes the provided script. - * Doesn't require to specify a script context in order to maintain backwards compatibility, internally uses - * the {@link org.elasticsearch.script.ScriptContext.Standard#GENERIC_PLUGIN} default context, assuming that it can only be called from plugins. - * - * @deprecated use the method variant that accepts the {@link ScriptContext} argument too: {@link #executable(String, String, ScriptType, ScriptContext, Map)} - */ - @Deprecated - public ExecutableScript executable(String lang, String script, ScriptType scriptType, Map vars) { - return executable(lang, script, scriptType, ScriptContext.Standard.GENERIC_PLUGIN, vars); - } - /** * Compiles (or retrieves from cache) and executes the provided script */ @@ -420,18 +396,6 @@ public class ScriptService extends AbstractComponent implements Closeable { return getScriptEngineServiceForLang(compiledScript.lang()).executable(compiledScript.compiled(), vars); } - /** - * Compiles (or retrieves from cache) and executes the provided search script - * Doesn't require to specify a script context in order to maintain backwards compatibility, internally uses - * the {@link org.elasticsearch.script.ScriptContext.Standard#GENERIC_PLUGIN} default context, assuming that it can only be called from plugins. - * - * @deprecated use the method variant that accepts the {@link ScriptContext} argument too: {@link #search(SearchLookup, String, String, ScriptType, ScriptContext, Map)} - */ - @Deprecated - public SearchScript search(SearchLookup lookup, String lang, String script, ScriptType scriptType, @Nullable Map vars) { - return search(lookup, lang, script, scriptType, ScriptContext.Standard.GENERIC_PLUGIN, vars); - } - /** * Compiles (or retrieves from cache) and executes the provided search script */