From ba4e7eb965a616f80d9517a587d39d6d1b72a634 Mon Sep 17 00:00:00 2001 From: Pete Cornish Date: Sat, 18 May 2024 19:53:24 +0100 Subject: [PATCH] fixup! refactor: splits modern and compat Graal implementations. --- .../graalvm/GraalvmCompatScriptingModule.kt | 56 +++++++++++++++++++ .../service/GraalvmCompatScriptServiceImpl.kt | 4 +- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 scripting/graalvm/src/main/java/io/gatehill/imposter/scripting/graalvm/GraalvmCompatScriptingModule.kt diff --git a/scripting/graalvm/src/main/java/io/gatehill/imposter/scripting/graalvm/GraalvmCompatScriptingModule.kt b/scripting/graalvm/src/main/java/io/gatehill/imposter/scripting/graalvm/GraalvmCompatScriptingModule.kt new file mode 100644 index 000000000..6070b784d --- /dev/null +++ b/scripting/graalvm/src/main/java/io/gatehill/imposter/scripting/graalvm/GraalvmCompatScriptingModule.kt @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016-2021. + * + * This file is part of Imposter. + * + * "Commons Clause" License Condition v1.0 + * + * The Software is provided to you by the Licensor under the License, as + * defined below, subject to the following condition. + * + * Without limiting other conditions in the License, the grant of rights + * under the License will not include, and the License does not grant to + * you, the right to Sell the Software. + * + * For purposes of the foregoing, "Sell" means practicing any or all of + * the rights granted to you under the License to provide to third parties, + * for a fee or other consideration (including without limitation fees for + * hosting or consulting/support services related to the Software), a + * product or service whose value derives, entirely or substantially, from + * the functionality of the Software. Any license notice or attribution + * required by the License must also include this Commons Clause License + * Condition notice. + * + * Software: Imposter + * + * License: GNU Lesser General Public License version 3 + * + * Licensor: Peter Cornish + * + * Imposter is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Imposter is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Imposter. If not, see . + */ +package io.gatehill.imposter.scripting.graalvm + +import com.google.inject.AbstractModule +import com.google.inject.Singleton +import io.gatehill.imposter.scripting.graalvm.service.GraalvmCompatScriptServiceImpl + +/** + * @author Pete Cornish + */ +class GraalvmCompatScriptingModule : AbstractModule() { + override fun configure() { + bind(GraalvmCompatScriptServiceImpl::class.java).`in`(Singleton::class.java) + } +} diff --git a/scripting/graalvm/src/main/java/io/gatehill/imposter/scripting/graalvm/service/GraalvmCompatScriptServiceImpl.kt b/scripting/graalvm/src/main/java/io/gatehill/imposter/scripting/graalvm/service/GraalvmCompatScriptServiceImpl.kt index 0ef446f4f..6c673cb55 100644 --- a/scripting/graalvm/src/main/java/io/gatehill/imposter/scripting/graalvm/service/GraalvmCompatScriptServiceImpl.kt +++ b/scripting/graalvm/src/main/java/io/gatehill/imposter/scripting/graalvm/service/GraalvmCompatScriptServiceImpl.kt @@ -51,7 +51,7 @@ import io.gatehill.imposter.script.ReadWriteResponseBehaviour import io.gatehill.imposter.script.RuntimeContext import io.gatehill.imposter.script.dsl.Dsl import io.gatehill.imposter.scripting.common.util.JavaScriptUtil -import io.gatehill.imposter.scripting.graalvm.GraalvmScriptingModule +import io.gatehill.imposter.scripting.graalvm.GraalvmCompatScriptingModule import io.gatehill.imposter.service.ScriptService import io.gatehill.imposter.service.ScriptSource import org.apache.logging.log4j.LogManager @@ -66,7 +66,7 @@ import javax.script.SimpleBindings * @author Pete Cornish */ @PluginInfo("js-graal-compat") -@RequireModules(GraalvmScriptingModule::class) +@RequireModules(GraalvmCompatScriptingModule::class) class GraalvmCompatScriptServiceImpl : ScriptService, Plugin { private val scriptEngine: ScriptEngine