Skip to content

Commit

Permalink
Improve docs for GraalVM Polyglot dependencies
Browse files Browse the repository at this point in the history
* Deprecate `jython` language indicator since only GraalVM Polyglot is there from now on
  • Loading branch information
artembilan committed Sep 25, 2024
1 parent 77ebee6 commit 52e8174
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")) {
Expand Down
3 changes: 3 additions & 0 deletions src/reference/antora/modules/ROOT/pages/scripting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 52e8174

Please sign in to comment.