diff --git a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/pom.xml b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/pom.xml
index a61fb086681..edd41514e40 100644
--- a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/pom.xml
+++ b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/pom.xml
@@ -102,9 +102,34 @@
org.openjdk.nashorn
nashorn-core
+
+
+ org.graalvm.sdk
+ graal-sdk
+
+
+ org.graalvm.js
+ js
+
+
+ org.graalvm.truffle
+ truffle-api
+
+
+ org.graalvm.regex
+ regex
+
+
+ com.ibm.icu
+ icu4j
+
org.apache.bsf.wso2
bsf-all
+
+ org.graalvm.js
+ js-scriptengine
+
diff --git a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutor.java b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutor.java
index bad297638a7..d1f06ce2668 100644
--- a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutor.java
+++ b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutor.java
@@ -27,6 +27,7 @@
import org.wso2.carbon.mediator.datamapper.engine.core.models.Model;
import org.wso2.carbon.mediator.datamapper.engine.core.models.StringModel;
import org.wso2.carbon.mediator.datamapper.engine.output.formatters.MapOutputFormatter;
+import org.wso2.carbon.mediator.datamapper.engine.utils.DataMapperEngineConstants;
import org.wso2.carbon.mediator.datamapper.engine.utils.DataMapperEngineUtils;
import org.wso2.carbon.mediator.datamapper.engine.utils.OpenJDKNashornFactoryWrapper;
@@ -88,6 +89,20 @@ public ScriptExecutor(ScriptExecutorType scriptExecutorType) {
log.debug("Setting Nashorn as Script Engine");
break;
}
+ case GRAALJS:
+ try {
+ scriptEngine = new ScriptEngineManager().getEngineByName(DataMapperEngineConstants.GRAALJS_ENGINE_NAME);
+ bindings = scriptEngine.createBindings();
+ log.debug("Setting Graal.js as Script Engine");
+ } catch (Exception e) {
+ log.warn("Could not find Graal.js jar in the lib, switching to rhino js. This may cause performance issue ");
+ log.debug(e);
+ scriptEngineManager.registerEngineName(DEFAULT_ENGINE_NAME, new RhinoScriptEngineFactory());
+ scriptEngine = scriptEngineManager.getEngineByName(DEFAULT_ENGINE_NAME);
+ bindings = scriptEngine.createBindings();
+ log.debug("Setting Rhino as Script Engine");
+ }
+ break;
case RHINO:
scriptEngineManager.registerEngineName(DEFAULT_ENGINE_NAME, new RhinoScriptEngineFactory());
scriptEngine = scriptEngineManager.getEngineByName(DEFAULT_ENGINE_NAME);
diff --git a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutorFactory.java b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutorFactory.java
index a5332cb272f..02b0dfeac8c 100644
--- a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutorFactory.java
+++ b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutorFactory.java
@@ -28,7 +28,7 @@
public class ScriptExecutorFactory {
private static ScriptExecutorPool executorPool = null;
- private static ScriptExecutorType scriptExecutorType = ScriptExecutorType.NASHORN;
+ private static ScriptExecutorType scriptExecutorType = ScriptExecutorType.GRAALJS;
private static final Log log = LogFactory.getLog(ScriptExecutorFactory.class);
/**
diff --git a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutorType.java b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutorType.java
index b9e7228440f..7d92b562e81 100644
--- a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutorType.java
+++ b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/core/executors/ScriptExecutorType.java
@@ -20,5 +20,5 @@
* This enum type represent the types of executors support in data mapper
*/
public enum ScriptExecutorType {
- RHINO, NASHORN
+ RHINO, NASHORN, GRAALJS
}
diff --git a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/utils/DataMapperEngineConstants.java b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/utils/DataMapperEngineConstants.java
index fd762507d76..5917f8928d9 100644
--- a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/utils/DataMapperEngineConstants.java
+++ b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper.engine/src/main/java/org/wso2/carbon/mediator/datamapper/engine/utils/DataMapperEngineConstants.java
@@ -32,6 +32,7 @@ public class DataMapperEngineConstants {
public static final String NULL_ELEMENT_TYPE = "null";
public static final String ARRAY_ELEMENT_FIRST_NAME = "0";
public static final String NASHORN_ENGINE_NAME = "nashorn";
+ public static final String GRAALJS_ENGINE_NAME = "graal.js";
public static final String DEFAULT_ENGINE_NAME = "js"; //rhino
public static final int DEFAULT_DATAMAPPER_ENGINE_POOL_SIZE = 20;
public static final String ORG_APACHE_SYNAPSE_DATAMAPPER_EXECUTOR_POOL_SIZE =
diff --git a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper/pom.xml b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper/pom.xml
index 9a14a27b428..08b65574720 100644
--- a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper/pom.xml
+++ b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper/pom.xml
@@ -67,5 +67,9 @@
org.wso2.carbon.mediation
org.wso2.carbon.mediator.datamapper.engine
+
+ org.graalvm.js
+ js
+
diff --git a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper/src/main/java/org/wso2/carbon/mediator/datamapper/DataMapperMediator.java b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper/src/main/java/org/wso2/carbon/mediator/datamapper/DataMapperMediator.java
index c2f800b471c..5872d3fcd3e 100644
--- a/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper/src/main/java/org/wso2/carbon/mediator/datamapper/DataMapperMediator.java
+++ b/components/mediators/datamapper/org.wso2.carbon.mediator.datamapper/src/main/java/org/wso2/carbon/mediator/datamapper/DataMapperMediator.java
@@ -755,6 +755,6 @@ private ScriptEngine getScriptExecutor() {
if (javaVersion.startsWith("1.7") || javaVersion.startsWith("1.6")) {
return new ScriptEngineManager().getEngineByName(DataMapperEngineConstants.DEFAULT_ENGINE_NAME);
}
- return new ScriptEngineManager().getEngineByName(DataMapperEngineConstants.NASHORN_ENGINE_NAME);
+ return new ScriptEngineManager().getEngineByName(DataMapperEngineConstants.GRAALJS_ENGINE_NAME);
}
}
diff --git a/pom.xml b/pom.xml
index a83ce3d28f1..690b5a08498 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2473,6 +2473,36 @@
bsf-all
${bsf.version}
+
+ org.graalvm.sdk
+ graal-sdk
+ ${graalvm.version}
+
+
+ org.graalvm.js
+ js-scriptengine
+ ${graalvm.version}
+
+
+ org.graalvm.js
+ js
+ ${graalvm.version}
+
+
+ org.graalvm.truffle
+ truffle-api
+ ${graalvm.version}
+
+
+ org.graalvm.regex
+ regex
+ ${graalvm.version}
+
+
+ com.ibm.icu
+ icu4j
+ ${icu.version}
+
org.wso2.runtime.diagnostics
runtime-diagnostics-tool
@@ -2671,6 +2701,8 @@
2.1.18.wso2v1
6.3.50
+ 23.0.4
+ 72.1
1.1.0