Skip to content

Commit d8b9d35

Browse files
committed
feat!: switches to GraalVM as the default JavaScript engine.
BREAKING CHANGE: The default JavaScript script engine has been changed from Nashorn to GraalVM. This provides a number of functional improvements, most notably, much more modern ECMAScript support.
1 parent 3e5ad26 commit d8b9d35

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

adapter/awslambda/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
implementation project (':mock:mock-openapi')
2727
implementation project (':mock:mock-rest')
2828
implementation project (':mock:mock-soap')
29-
implementation project (':scripting:scripting-nashorn')
29+
implementation project (':scripting:scripting-graalvm')
3030
implementation project (':store:store-dynamodb')
3131
implementation project (':store:store-inmem')
3232

adapter/awslambda/src/main/java/io/gatehill/imposter/awslambda/util/PluginUtil.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import io.gatehill.imposter.plugin.openapi.OpenApiPluginImpl
5151
import io.gatehill.imposter.plugin.rest.RestPluginImpl
5252
import io.gatehill.imposter.plugin.soap.SoapModule
5353
import io.gatehill.imposter.plugin.soap.SoapPluginImpl
54-
import io.gatehill.imposter.scripting.nashorn.NashornScriptingModule
55-
import io.gatehill.imposter.scripting.nashorn.service.NashornScriptServiceImpl
54+
import io.gatehill.imposter.scripting.graalvm.GraalvmScriptingModule
55+
import io.gatehill.imposter.scripting.graalvm.service.GraalvmScriptServiceImpl
5656
import io.gatehill.imposter.store.dynamodb.DynamoDBStoreFactoryImpl
5757
import io.gatehill.imposter.store.dynamodb.DynamoDBStoreModule
5858
import io.gatehill.imposter.store.inmem.InMemoryStoreFactoryImpl
@@ -64,7 +64,7 @@ object PluginUtil {
6464
"openapi" to OpenApiPluginImpl::class.java,
6565
"rest" to RestPluginImpl::class.java,
6666
"soap" to SoapPluginImpl::class.java,
67-
"js-nashorn" to NashornScriptServiceImpl::class.java,
67+
"js-graal" to GraalvmScriptServiceImpl::class.java,
6868
"store-inmem" to InMemoryStoreFactoryImpl::class.java,
6969
"store-dynamodb" to DynamoDBStoreFactoryImpl::class.java,
7070
)
@@ -73,7 +73,7 @@ object PluginUtil {
7373
LambdaModule(),
7474
OpenApiModule(),
7575
SoapModule(),
76-
NashornScriptingModule(),
76+
GraalvmScriptingModule(),
7777
DynamoDBStoreModule(),
7878
InMemoryStoreModule(),
7979
)

docs/environment_variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The following environment variables are supported:
1313
| IMPOSTER_ESCAPE_COLONS_IN_PATH | Escape colons in paths. | `false` | `true` |
1414
| IMPOSTER_FEATURES | Enables or disables features. See [Features](./features.md) documentation. | Per [default features](./features.md). | `metrics=false,stores=true` |
1515
| IMPOSTER_IGNORE_CONFIG_ERRORS | Log errors encountered during configuration parsing or plugin configuration instead of throwing an exception. Defaults to `false`, as skipping a configuration might also skip the security conditions it contains. | `false` | boolean |
16-
| IMPOSTER_JS_PLUGIN | Sets the JavaScript implementation. | `js-nashorn` | Can be changed to `js-graal` plugin, if installed. |
16+
| IMPOSTER_JS_PLUGIN | Sets the JavaScript implementation. | `js-graal` | Can be changed to `js-nashorn` plugin, if installed. |
1717
| IMPOSTER_LOG_LEVEL | Sets logging level. | `DEBUG` | `INFO`, `DEBUG`, `TRACE` |
1818
| IMPOSTER_LOG_REQUEST_BODY | Include request in structured log entries. | `false` | `true` - See [Metrics, logs and telemetry](./metrics_logs_telemetry.md). |
1919
| IMPOSTER_LOG_REQUEST_HEADERS | Comma separated list of request headers to add to structured log entries. | Empty | `X-Correlation-ID,User-Agent` - See [Metrics, logs and telemetry](./metrics_logs_telemetry.md). |

docs/plugins.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ Imposter uses plugins to control its behaviour and provide specialised mocks.
66
77
The following table describes the available plugins.
88

9-
| Category | Plugin name | Description | Details |
10-
|----------------|-------------------|----------------------------------------|----------------------------------------------------------------------------------------------------|
11-
| Mock | `hbase` | HBase mocks. | See [HBase plugin](hbase_plugin.md). |
12-
| Mock | `openapi` | OpenAPI (and Swagger) mocks. | Built-in. See [OpenAPI (and Swagger) plugin](openapi_plugin.md). |
13-
| Mock | `rest` | REST mocks. | Built-in. See [REST plugin](rest_plugin.md). |
14-
| Mock | `sfdc` | SFDC (Salesforce) mocks. | See [SFDC (Salesforce) plugin](sfdc_plugin.md). |
15-
| Mock | `soap` | SOAP (and WSDL) mocks. | Built-in. See [SOAP plugin](soap_plugin.md). |
16-
| Mock | `wiremock` | WireMock mappings support. | See [WireMock plugin](wiremock_plugin.md). |
17-
| Scripting | `js-graal` | Graal.js scripting. | Graal.js JavaScript scripting support. See [Modern JavaScript features](./scripting_modern_js.md). |
18-
| Scripting | `js-nashorn` | Nashorn scripting. | This is the default JavaScript script engine |
19-
| Store | `store-dynamodb` | DynamoDB store implementation. | See [DynamoDB store](https://github.com/outofcoffee/imposter/tree/main/store/dynamodb). |
20-
| Store | `store-redis` | Redis store implementation. | See [Redis store](https://github.com/outofcoffee/imposter/tree/main/store/redis). |
21-
| Store | `store-graphql` | GraphQL store queries. | See [GraphQL](stores_graphql.md). |
22-
| Configuration | `config-detector` | Detects plugins from `*-config` files. | Built-in |
23-
| Configuration | `meta-detector` | Detects plugins from `META-INF`. | Built-in |
24-
| Data generator | `fake-data` | Generates fake data. | See [Fake data generator](fake_data.md). |
9+
| Category | Plugin name | Description | Details |
10+
|----------------|-------------------|----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
11+
| Mock | `hbase` | HBase mocks. | See [HBase plugin](hbase_plugin.md). |
12+
| Mock | `openapi` | OpenAPI (and Swagger) mocks. | Built-in. See [OpenAPI (and Swagger) plugin](openapi_plugin.md). |
13+
| Mock | `rest` | REST mocks. | Built-in. See [REST plugin](rest_plugin.md). |
14+
| Mock | `sfdc` | SFDC (Salesforce) mocks. | See [SFDC (Salesforce) plugin](sfdc_plugin.md). |
15+
| Mock | `soap` | SOAP (and WSDL) mocks. | Built-in. See [SOAP plugin](soap_plugin.md). |
16+
| Mock | `wiremock` | WireMock mappings support. | See [WireMock plugin](wiremock_plugin.md). |
17+
| Scripting | `js-graal` | Graal.js scripting. | Graal.js JavaScript scripting support. This is the default JavaScript script engine. See [Modern JavaScript features](./scripting_modern_js.md). |
18+
| Scripting | `js-nashorn` | Nashorn scripting. | This is the legacy JavaScript script engine |
19+
| Store | `store-dynamodb` | DynamoDB store implementation. | See [DynamoDB store](https://github.com/outofcoffee/imposter/tree/main/store/dynamodb). |
20+
| Store | `store-redis` | Redis store implementation. | See [Redis store](https://github.com/outofcoffee/imposter/tree/main/store/redis). |
21+
| Store | `store-graphql` | GraphQL store queries. | See [GraphQL](stores_graphql.md). |
22+
| Configuration | `config-detector` | Detects plugins from `*-config` files. | Built-in |
23+
| Configuration | `meta-detector` | Detects plugins from `META-INF`. | Built-in |
24+
| Data generator | `fake-data` | Generates fake data. | See [Fake data generator](fake_data.md). |
2525

2626
## Plugin loading
2727

scripting/common/src/main/java/io/gatehill/imposter/scripting/common/util/JavaScriptUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ object JavaScriptUtil {
8383
* @return the plugin name of the active JavaScript implementation
8484
*/
8585
val activePlugin: String
86-
get() = EnvVars.getEnv(envJsPlugin) ?: "js-nashorn"
86+
get() = EnvVars.getEnv(envJsPlugin) ?: "js-graal"
8787

8888
fun transformRuntimeMap(runtimeContext: RuntimeContext, addDslPrefix: Boolean, addConsoleShim: Boolean): Map<String, *> {
8989
val runtimeObjects = runtimeContext.asMap().toMutableMap()

server/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ dependencies {
1010
api project(':core:imposter-engine')
1111

1212
// scripting
13-
implementation project (':scripting:scripting-groovy')
14-
implementation project(':scripting:scripting-nashorn')
13+
implementation project(':scripting:scripting-groovy')
14+
implementation project(':scripting:scripting-graalvm')
1515

1616
// needed for plugin delegation
1717
implementation project(':scripting:scripting-common')

0 commit comments

Comments
 (0)