From 52e8174c66308a79497b546a928247fc9800886c Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Wed, 25 Sep 2024 13:03:07 -0400 Subject: [PATCH] Improve docs for GraalVM Polyglot dependencies * Deprecate `jython` language indicator since only GraalVM Polyglot is there from now on --- .../scripting/jsr223/ScriptExecutorFactory.java | 14 +++++++++++++- .../antora/modules/ROOT/pages/scripting.adoc | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/ScriptExecutorFactory.java b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/ScriptExecutorFactory.java index bb44a0d5fb..48422fd627 100644 --- a/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/ScriptExecutorFactory.java +++ b/spring-integration-scripting/src/main/java/org/springframework/integration/scripting/jsr223/ScriptExecutorFactory.java @@ -19,6 +19,9 @@ import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.springframework.integration.scripting.PolyglotScriptExecutor; import org.springframework.integration.scripting.ScriptExecutor; import org.springframework.util.Assert; @@ -33,8 +36,17 @@ */ public final class ScriptExecutorFactory { + private static final Log LOGGER = LogFactory.getLog(ScriptExecutorFactory.class); + public static ScriptExecutor getScriptExecutor(String language) { - if (language.equalsIgnoreCase("python") || language.equalsIgnoreCase("jython")) { + if (language.equalsIgnoreCase("jython")) { + LOGGER.warn(""" + The 'jython' language indicator is deprecated and will be removed in the next version. + The Python support is fully based on GraalVM Polyglot and there is no 'jython' dependency requirement any more. + """); + return new PolyglotScriptExecutor("python"); + } + else if (language.equalsIgnoreCase("python")) { return new PolyglotScriptExecutor("python"); } else if (language.equalsIgnoreCase("ruby") || language.equalsIgnoreCase("jruby")) { diff --git a/src/reference/antora/modules/ROOT/pages/scripting.adoc b/src/reference/antora/modules/ROOT/pages/scripting.adoc index 8cfb5856fd..ddbace3806 100644 --- a/src/reference/antora/modules/ROOT/pages/scripting.adoc +++ b/src/reference/antora/modules/ROOT/pages/scripting.adoc @@ -296,10 +296,13 @@ They are mutually exclusive. Starting with version 6.0, the framework provides a `PolyglotScriptExecutor` which is based the https://www.graalvm.org/latest/reference-manual/languages/[GraalVM Polyglot API]. The JSR223 engine implementation for JavaScript, removed from Java by itself, has been replaced by using this new script executor. See more information about enabling JavaScript support in GraalVM and what https://www.graalvm.org/latest/reference-manual/js/[configuration options] can be propagated via script variables. +In particular, an `org.graalvm.polyglot:js` dependency has to be added to the target project to support JavaScript. + Starting with version 6.4, the Python scripts support has been migrated to GraalVM Polyglot as well. Now these scripts can be written in Python 3.x and can use third-party libraries. See https://www.graalvm.org/latest/reference-manual/python/[GraalPy] documentation for more information. +In particular, an `rg.graalvm.polyglot:python` dependency has to be added to the target project to support JavaScript. By default, the framework sets `allowAllAccess` to `true` on the shared Polyglot `Context` which enables this interaction with host JVM: