GH-3664: Re-enable JavaScript support via GraalVM (#3911)
* GH-3664: Re-enable JavaScript support via GraalVM Fixes https://github.com/spring-projects/spring-integration/issues/3664 The JavaScript JSR223 engine has been removed from Java. Migrate JavaScript support into GraalVM Polyglot API: * Implement `PolyglotScriptExecutor` which can also support other GraalVM languages * Change the `ScriptExecutorFactory` to use a `PolyglotScriptExecutor` when it encounters JavaScript * Re-enable tests for JavaScript * Add GraalVM Polyglot support into docs * * Reinstate `@EnabledIfSystemProperty` for GraalVM JS system property
This commit is contained in:
@@ -5,9 +5,6 @@ Spring Integration 2.1 added support for the https://www.jcp.org/en/jsr/detail?i
|
||||
It lets you use scripts written in any supported language (including Ruby, JRuby, Groovy and Kotlin) to provide the logic for various integration components, similar to the way the Spring Expression Language (SpEL) is used in Spring Integration.
|
||||
For more information about JSR223, see the https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/api.html[documentation].
|
||||
|
||||
NOTE: Starting with Java 11, the Nashorn JavaScript Engine has been deprecated with possible removal in Java 15.
|
||||
It is recommended to reconsider it in favor of other scripting language from now on.
|
||||
|
||||
You need to include this dependency into your project:
|
||||
|
||||
====
|
||||
@@ -32,7 +29,6 @@ In addition, you need to add a script engine implementation, e.g. JRuby, Jython.
|
||||
Starting with version 5.2, Spring Integration provides a Kotlin Jsr223 support.
|
||||
You need to add these dependencies into your project to make it working:
|
||||
|
||||
|
||||
====
|
||||
[source, xml, subs="normal", role="primary"]
|
||||
.Maven
|
||||
@@ -279,3 +275,24 @@ If a `script-variable-generator` is not provided, script components use `Default
|
||||
|
||||
IMPORTANT: You cannot provide both the `script-variable-generator` attribute and `<variable>` element(s).
|
||||
They are mutually exclusive.
|
||||
|
||||
[[graalmv-polyglot]]
|
||||
===== GraalVM Polyglot
|
||||
|
||||
Starting with version 6.0, the framework provides a `PolyglotScriptExecutor` which is based the https://www.graalvm.org/22.2/reference-manual/embed-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/22.2/reference-manual/js[configuration options] can be propagated via script variables.
|
||||
By default, the framework sets `allowAllAccess` to `true` on the shared Polyglot `Context` which enables this interaction with host JVM:
|
||||
|
||||
* The creation and use of new threads.
|
||||
* The access to public host classes.
|
||||
* The loading of new host classes by adding entries to the class path.
|
||||
* Exporting new members into the polyglot bindings.
|
||||
* Unrestricted IO operations on host system.
|
||||
* Passing experimental options.
|
||||
* The creation and use of new sub-processes.
|
||||
* The access to process environment variables.
|
||||
|
||||
This can be customized via overloaded `PolyglotScriptExecutor` constructor which accepts a `org.graalvm.polyglot.Context.Builder`.
|
||||
|
||||
The usage of JavaScript in the framework components remains the same, on ly the difference that now it is going to work only on GraalVM with installed `js` component.
|
||||
|
||||
@@ -63,6 +63,13 @@ See <<./sftp.adoc#sftp,SFTP Adapters>> for more information.
|
||||
Enabling observation for timers and tracing using Micrometer is now supported.
|
||||
See <<./metrics.adoc#micrometer-observation,Micrometer Observation>> for more information.
|
||||
|
||||
[[x6.0-graalmv-polyglot]]
|
||||
==== GraalVM Polyglot Support
|
||||
|
||||
The Scripting module now provides a `PolyglotScriptExecutor` implementation based on the GraalVM Polyglot support.
|
||||
JavaScript support is now based on this executor since its JSR223 implementation has been removed from Java by itself.
|
||||
See <<./scripting.adoc#scripting,Scripting Support>> for more information.
|
||||
|
||||
[[x6.0-general]]
|
||||
=== General Changes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user