summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/blueprint-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-scripts')
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/pom.xml60
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompiledScript.kt56
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompilerProxy.kt154
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptingHost.kt94
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsConfiguration.kt58
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsServiceImpl.kt71
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintKotlinScript0
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BlueprintScriptingHostTest.kt84
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts1/simple.cba.kts56
-rw-r--r--ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts2/simple.cba.kts56
10 files changed, 0 insertions, 689 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml
deleted file mode 100644
index 2f4b0472d..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>modules</artifactId>
- <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
- <version>0.5.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>blueprint-scripts</artifactId>
- <name>Controller Blueprints Scripts</name>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
- <artifactId>resource-dict</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-compiler-embeddable</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-scripting-jvm-host</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-compiler</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-script-util</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-script-runtime</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlin-test-junit</artifactId>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompiledScript.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompiledScript.kt
deleted file mode 100644
index e926b9828..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompiledScript.kt
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.controllerblueprints.scripts
-
-import java.io.File
-import java.io.Serializable
-import java.net.URL
-import java.net.URLClassLoader
-import kotlin.reflect.KClass
-import kotlin.script.experimental.api.*
-
-open class BluePrintCompiledScript<out JarFile : File>(
- private val scriptCompilationConfiguration: ScriptCompilationConfiguration,
- private val compiledJar: File) :
- CompiledScript<JarFile>, Serializable {
-
- lateinit var scriptClassFQName: String
-
- override val compilationConfiguration: ScriptCompilationConfiguration
- get() = scriptCompilationConfiguration
-
- override suspend fun getClass(scriptEvaluationConfiguration: ScriptEvaluationConfiguration?): ResultWithDiagnostics<KClass<*>> = try {
-
- val baseClassLoader = Thread.currentThread().contextClassLoader
-
- val urls = arrayListOf<URL>()
- urls.add(compiledJar.toURI().toURL())
- val classLoaderWithDependencies = URLClassLoader(urls.toTypedArray(), baseClassLoader)
-
- val clazz = classLoaderWithDependencies.loadClass(scriptClassFQName).kotlin
- clazz.asSuccess()
- } catch (e: Throwable) {
- ResultWithDiagnostics.Failure(
- ScriptDiagnostic(
- "Unable to instantiate class $scriptClassFQName",
- exception = e
- )
- )
- }
-
-}
-
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompilerProxy.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompilerProxy.kt
deleted file mode 100644
index 6e88ba31a..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompilerProxy.kt
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.controllerblueprints.scripts
-
-import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
-import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots
-import org.jetbrains.kotlin.cli.common.environment.setIdeaIoUseFallback
-import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
-import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
-import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
-import org.jetbrains.kotlin.cli.common.messages.MessageCollector
-import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
-import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
-import org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler
-import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
-import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer
-import org.jetbrains.kotlin.config.*
-import org.slf4j.LoggerFactory
-import java.io.File
-import kotlin.script.experimental.api.*
-import kotlin.script.experimental.host.ScriptingHostConfiguration
-import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
-import kotlin.script.experimental.jvmhost.KJvmCompilerProxy
-
-open class BluePrintsCompilerProxy(private val hostConfiguration: ScriptingHostConfiguration) : KJvmCompilerProxy {
-
- private val log = LoggerFactory.getLogger(BluePrintsCompilerProxy::class.java)!!
-
- override fun compile(script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration)
- : ResultWithDiagnostics<CompiledScript<*>> {
-
- val messageCollector = ScriptDiagnosticsMessageCollector()
-
- fun failure(vararg diagnostics: ScriptDiagnostic): ResultWithDiagnostics.Failure =
- ResultWithDiagnostics.Failure(*messageCollector.diagnostics.toTypedArray(), *diagnostics)
-
- // Compile the Code
- try {
-
- log.trace("Scripting Host Configuration : $hostConfiguration")
-
- setIdeaIoUseFallback()
-
- val blueprintSourceCode = script as BluePrintSourceCode
-
- val compiledJarFile = blueprintSourceCode.targetJarFile
-
- if (!compiledJarFile.exists() || blueprintSourceCode.regenerate) {
-
- var environment: KotlinCoreEnvironment? = null
-
- val rootDisposable = Disposer.newDisposable()
-
- try {
-
- val compilerConfiguration = CompilerConfiguration().apply {
-
- put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector)
- put(CommonConfigurationKeys.MODULE_NAME, blueprintSourceCode.moduleName)
- put(JVMConfigurationKeys.OUTPUT_JAR, compiledJarFile)
- put(JVMConfigurationKeys.RETAIN_OUTPUT_IN_MEMORY, false)
-
- // Load Current Class loader to Compilation Class loader
- val currentClassLoader = classpathFromClasspathProperty()
- currentClassLoader?.forEach {
- add(CLIConfigurationKeys.CONTENT_ROOTS, JvmClasspathRoot(it))
- }
-
- // Add all Kotlin Sources
- addKotlinSourceRoots(blueprintSourceCode.blueprintKotlinSources)
-
- languageVersionSettings = LanguageVersionSettingsImpl(
- LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE, mapOf(AnalysisFlags.skipMetadataVersionCheck to true)
- )
- }
-
- //log.info("Executing with compiler configuration : $compilerConfiguration")
-
- environment = KotlinCoreEnvironment.createForProduction(rootDisposable, compilerConfiguration,
- EnvironmentConfigFiles.JVM_CONFIG_FILES)
-
- // Compile Kotlin Sources
- val compiled = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment)
-
- val analyzerWithCompilerReport = AnalyzerWithCompilerReport(messageCollector,
- environment.configuration.languageVersionSettings)
-
- if (analyzerWithCompilerReport.hasErrors()) {
- return ResultWithDiagnostics.Failure(messageCollector.diagnostics)
- }
- } finally {
- rootDisposable.dispose()
- }
- }
-
- val res = BluePrintCompiledScript<File>(scriptCompilationConfiguration, compiledJarFile)
-
- return ResultWithDiagnostics.Success(res, messageCollector.diagnostics)
-
- } catch (ex: Throwable) {
- return failure(ex.asDiagnostics())
- }
- }
-}
-
-class ScriptDiagnosticsMessageCollector : MessageCollector {
-
- private val _diagnostics = arrayListOf<ScriptDiagnostic>()
-
- val diagnostics: List<ScriptDiagnostic> get() = _diagnostics
-
- override fun clear() {
- _diagnostics.clear()
- }
-
- override fun hasErrors(): Boolean =
- _diagnostics.any { it.severity == ScriptDiagnostic.Severity.ERROR }
-
-
- override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation?) {
- val mappedSeverity = when (severity) {
- CompilerMessageSeverity.EXCEPTION,
- CompilerMessageSeverity.ERROR -> ScriptDiagnostic.Severity.ERROR
- CompilerMessageSeverity.STRONG_WARNING,
- CompilerMessageSeverity.WARNING -> ScriptDiagnostic.Severity.WARNING
- CompilerMessageSeverity.INFO -> ScriptDiagnostic.Severity.INFO
- CompilerMessageSeverity.LOGGING -> ScriptDiagnostic.Severity.DEBUG
- else -> null
- }
- if (mappedSeverity != null) {
- val mappedLocation = location?.let {
- if (it.line < 0 && it.column < 0) null // special location created by CompilerMessageLocation.create
- else SourceCode.Location(SourceCode.Position(it.line, it.column))
- }
- _diagnostics.add(ScriptDiagnostic(message, mappedSeverity, location?.path, mappedLocation))
- }
- }
-}
-
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptingHost.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptingHost.kt
deleted file mode 100644
index fa1488463..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptingHost.kt
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.controllerblueprints.scripts
-
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.slf4j.LoggerFactory
-import java.util.*
-import kotlin.script.experimental.api.*
-import kotlin.script.experimental.host.BasicScriptingHost
-import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
-import kotlin.script.experimental.jvmhost.JvmScriptCompiler
-import kotlin.script.experimental.jvmhost.impl.withDefaults
-
-val blueprintScriptCompiler = JvmScriptCompiler(defaultJvmScriptingHostConfiguration,
- BluePrintsCompilerProxy(defaultJvmScriptingHostConfiguration.withDefaults()))
-
-open class BlueprintScriptingHost(evaluator: ScriptEvaluator) : BasicScriptingHost(blueprintScriptCompiler, evaluator) {
-
- override fun eval(
- script: SourceCode,
- scriptCompilationConfiguration: ScriptCompilationConfiguration,
- configuration: ScriptEvaluationConfiguration?
- ): ResultWithDiagnostics<EvaluationResult> =
-
- runInCoroutineContext {
-
- compiler(script, scriptCompilationConfiguration)
- .onSuccess {
- evaluator(it, configuration)
- }.onFailure { failedResult ->
- val messages = failedResult.reports?.joinToString("\n")
- throw BluePrintProcessorException(messages)
- }
- }
-}
-
-open class BluePrintScriptEvaluator(private val scriptClassName: String) : ScriptEvaluator {
-
- private val log = LoggerFactory.getLogger(BluePrintScriptEvaluator::class.java)!!
-
- override suspend operator fun invoke(
- compiledScript: CompiledScript<*>,
- scriptEvaluationConfiguration: ScriptEvaluationConfiguration?
- ): ResultWithDiagnostics<EvaluationResult> =
- try {
- log.debug("Getting script class name($scriptClassName) from the compiled sources ")
- val bluePrintCompiledScript = compiledScript as BluePrintCompiledScript
- bluePrintCompiledScript.scriptClassFQName = scriptClassName
-
- val res = compiledScript.getClass(scriptEvaluationConfiguration)
- when (res) {
- is ResultWithDiagnostics.Failure -> res
- is ResultWithDiagnostics.Success -> {
-
- val scriptClass = res.value
- val args = ArrayList<Any?>()
- scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.providedProperties)?.forEach {
- args.add(it.value)
- }
- scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.implicitReceivers)?.let {
- args.addAll(it)
- }
- scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.constructorArgs)?.let {
- args.addAll(it)
- }
-
- val instance = scriptClass.java.constructors.single().newInstance(*args.toArray())
- ?: throw BluePrintProcessorException("failed to create instance from the script")
-
- log.info("Created script instance of type ${instance.javaClass}")
-
- ResultWithDiagnostics.Success(EvaluationResult(ResultValue.Value(scriptClass.qualifiedName!!,
- instance, "", instance),
- scriptEvaluationConfiguration))
- }
- }
- } catch (e: Throwable) {
- ResultWithDiagnostics.Failure(e.asDiagnostics("Error evaluating script"))
- }
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsConfiguration.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsConfiguration.kt
deleted file mode 100644
index 96d459066..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsConfiguration.kt
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.controllerblueprints.scripts
-
-import java.io.File
-import kotlin.script.experimental.annotations.KotlinScript
-import kotlin.script.experimental.api.*
-import kotlin.script.experimental.jvm.jvm
-import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
-
-@KotlinScript(
- fileExtension = "cba.kts",
- compilationConfiguration = BluePrintScripCompilationConfiguration::class,
- displayName = "Controller Blueprint Archive Kotlin Scripts"
-)
-abstract class BluePrintKotlinScript
-
-object BluePrintScripCompilationConfiguration : ScriptCompilationConfiguration(
- {
- jvm {
- //classpathFromClassloader(BluePrintScripCompilationConfiguration::class.java.classLoader)
- classpathFromClasspathProperty()
- }
- ide{
- acceptedLocations(ScriptAcceptedLocation.Everywhere)
- }
-
- }
-)
-
-open class BluePrintSourceCode : SourceCode {
- lateinit var blueprintKotlinSources: MutableList<String>
- lateinit var moduleName: String
- lateinit var targetJarFile: File
- var regenerate: Boolean = false
-
- override val text: String
- get() = ""
-
- override val locationId: String? = null
-
- override val name: String?
- get() = moduleName
-}
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsServiceImpl.kt
deleted file mode 100644
index 9438c1f4b..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsServiceImpl.kt
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.controllerblueprints.scripts
-
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintScriptsService
-import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
-import org.springframework.stereotype.Service
-import java.io.File
-import java.util.*
-import kotlin.script.experimental.api.ResultValue
-import kotlin.script.experimental.api.resultOrNull
-import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate
-
-@Service
-open class BluePrintScriptsServiceImpl : BluePrintScriptsService {
-
- override suspend fun <T> scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String,
- reCompile: Boolean): T {
-
- val kotlinScriptPath = blueprintContext.rootPath.plus(File.separator)
- .plus(BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR)
-
- val compiledJar = kotlinScriptPath.plus(File.separator)
- .plus(bluePrintScriptsJarName(blueprintContext))
-
- val scriptSource = BluePrintSourceCode()
-
- val sources: MutableList<String> = arrayListOf()
- sources.add(kotlinScriptPath)
- scriptSource.blueprintKotlinSources = sources
- scriptSource.moduleName = "${blueprintContext.name()}-${blueprintContext.version()}-cba-kts"
- scriptSource.targetJarFile = File(compiledJar)
- scriptSource.regenerate = reCompile
-
- val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<BluePrintKotlinScript>()
- val scriptEvaluator = BluePrintScriptEvaluator(scriptClassName)
-
- val compiledResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource, compilationConfiguration,
- null)
-
- val returnValue = compiledResponse.resultOrNull()?.returnValue as? ResultValue.Value
-
- return returnValue?.value!! as T
- }
-
- override suspend fun <T> scriptInstance(scriptClassName: String): T {
- val args = ArrayList<Any?>()
- return Thread.currentThread().contextClassLoader.loadClass(scriptClassName).constructors
- .single().newInstance(*args.toArray()) as T
- }
-
- private fun bluePrintScriptsJarName(blueprintContext: BluePrintContext): String {
- return "${blueprintContext.name()}-${blueprintContext.version()}-cba-kts.jar"
- }
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintKotlinScript b/ms/controllerblueprints/modules/blueprint-scripts/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintKotlinScript
deleted file mode 100644
index e69de29bb..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintKotlinScript
+++ /dev/null
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BlueprintScriptingHostTest.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BlueprintScriptingHostTest.kt
deleted file mode 100644
index 2c597ea2b..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BlueprintScriptingHostTest.kt
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.cds.controllerblueprints.scripts
-
-
-import org.apache.commons.io.FileUtils
-import org.junit.Test
-import java.io.File
-import kotlin.script.experimental.jvm.util.classpathFromClass
-import kotlin.script.experimental.jvm.util.classpathFromClassloader
-import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty
-import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate
-
-class BlueprintScriptingHostTest {
-
- private fun viewClassPathInfo() {
-
- println(" *********** classpathFromClass *********** ")
- classpathFromClass(BlueprintScriptingHostTest::class.java.classLoader,
- BlueprintScriptingHostTest::class)!!
- .forEach(::println)
-
- println(" *********** classpathFromClassloader *********** ")
- classpathFromClassloader(BlueprintScriptingHostTest::class.java.classLoader)!!
- .forEach(::println)
-
- println(" *********** classpathFromClasspathProperty *********** ")
- classpathFromClasspathProperty()!!
- .forEach(::println)
- }
-
- @Test
- fun `test same script two folders`() {
-
- FileUtils.forceMkdir(File("target/scripts1/"))
- FileUtils.forceMkdir(File("target/scripts2/"))
-
- val scriptSource1 = BluePrintSourceCode()
- scriptSource1.moduleName = "blueprint-test-script"
-
- scriptSource1.targetJarFile = File("target/scripts1/blueprint-script-generated.jar")
- val sources1: MutableList<String> = arrayListOf()
- sources1.add("src/test/resources/scripts1")
- scriptSource1.blueprintKotlinSources = sources1
-
- val scriptClassName = "Simple_cba\$SampleComponentFunction"
-
- val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<BluePrintKotlinScript>()
-
- val scriptEvaluator = BluePrintScriptEvaluator(scriptClassName)
-
- val scriptSource2 = BluePrintSourceCode()
- scriptSource2.moduleName = "blueprint-test-script"
-
- scriptSource2.targetJarFile = File("target/scripts2/blueprint-script-generated.jar")
- val sources2: MutableList<String> = arrayListOf()
- sources2.add("src/test/resources/scripts2")
- scriptSource2.blueprintKotlinSources = sources2
-
- for (i in 1..2) {
- val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource1, compilationConfiguration,
- null)
- }
-
- for (i in 1..2) {
- val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource2, compilationConfiguration,
- null)
- }
- }
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts1/simple.cba.kts b/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts1/simple.cba.kts
deleted file mode 100644
index 4fffda051..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts1/simple.cba.kts
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
-import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
-import org.springframework.stereotype.Service
-
-@Service
-open class SampleComponentFunction : BlueprintFunctionNode<String, String> {
-
- override fun getName(): String {
- println("Printing Name....." + "sample".asJsonPrimitive())
- return "my Name"
- }
-
- override suspend fun prepareRequestNB(executionRequest: String): String {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override suspend fun processNB(executionRequest: String) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: String) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override suspend fun prepareResponseNB(): String {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override suspend fun applyNB(t: String): String {
- return "Script 1 response - $t"
- }
-}
-
-val blueprintFunction = SampleComponentFunction()
-
-val serviceTemplate = ServiceTemplate()
-
-println("Simple script printing....")
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts2/simple.cba.kts b/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts2/simple.cba.kts
deleted file mode 100644
index 4ba56c491..000000000
--- a/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts2/simple.cba.kts
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2019 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
-import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
-import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
-import org.springframework.stereotype.Service
-
-@Service
-open class SampleComponentFunction : BlueprintFunctionNode<String, String> {
-
- override fun getName(): String {
- println("Printing Name....." + "sample".asJsonPrimitive())
- return "my Name"
- }
-
- override suspend fun prepareRequestNB(executionRequest: String): String {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override suspend fun processNB(executionRequest: String) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: String) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override suspend fun prepareResponseNB(): String {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override suspend fun applyNB(t: String): String {
- return "Script 2 response - $t"
- }
-}
-
-val blueprintFunction = SampleComponentFunction()
-
-val serviceTemplate = ServiceTemplate()
-
-println("Simple script printing....")