Refractor blueprint-script to avoid cyclic dependency. 95/91195/2
authorBrinda Santh <brindasanth@in.ibm.com>
Wed, 10 Jul 2019 22:27:23 +0000 (18:27 -0400)
committerBrinda Santh Muthuramalingam <brindasanth@in.ibm.com>
Wed, 10 Jul 2019 22:35:15 +0000 (22:35 +0000)
There is a possibility of cyclic dependencies between blueprint-script module and code module. To avoid cyclic dependency blueprint-script implementation should be moved to Core module.
This implementation has zero impact on code functionality and code testing.

Change-Id: Ic18ea848cb2e1e2e7a5f1c144714de26d1495cee
Issue-ID: CCSDK-1469
Signed-off-by: Brinda Santh <brindasanth@in.ibm.com>
21 files changed:
ms/blueprintsprocessor/functions/cli-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/ComponentCliExecutorTest.kt
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
ms/blueprintsprocessor/modules/services/execution-service/pom.xml
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/AbstractComponentFunctionTest.kt
ms/controllerblueprints/modules/blueprint-core/pom.xml
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/FileExtensionFunctions.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompiledScript.kt [moved from ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompiledScript.kt with 96% similarity]
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerProxy.kt [moved from ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintCompilerProxy.kt with 99% similarity]
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt [moved from ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptingHost.kt with 98% similarity]
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsConfiguration.kt [moved from ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsConfiguration.kt with 96% similarity]
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt [moved from ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BluePrintScriptsServiceImpl.kt with 96% similarity]
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintKotlinScript [moved from ms/controllerblueprints/modules/blueprint-scripts/src/main/resources/META-INF/kotlin/script/templates/org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintKotlinScript with 100% similarity]
ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptingHostTest.kt [moved from ms/controllerblueprints/modules/blueprint-scripts/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/scripts/BlueprintScriptingHostTest.kt with 98% similarity]
ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts1/simple.cba.kts [moved from ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts1/simple.cba.kts with 100% similarity]
ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts2/simple.cba.kts [moved from ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts2/simple.cba.kts with 100% similarity]
ms/controllerblueprints/modules/blueprint-scripts/pom.xml [deleted file]
ms/controllerblueprints/modules/pom.xml
ms/controllerblueprints/modules/service/pom.xml
ms/controllerblueprints/parent/pom.xml

index 658092f..e9cfddc 100644 (file)
@@ -38,7 +38,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
 import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.cds.controllerblueprints.scripts.BluePrintScriptsServiceImpl
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.test.annotation.DirtiesContext
 import org.springframework.test.context.ContextConfiguration
index 66fdd8f..4a4bcc0 100644 (file)
@@ -31,7 +31,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
 import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
-import org.onap.ccsdk.cds.controllerblueprints.scripts.BluePrintScriptsServiceImpl
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.test.context.ContextConfiguration
 import org.springframework.test.context.TestPropertySource
index edfa4e3..a48d4e0 100644 (file)
             <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
             <artifactId>blueprint-core</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
-            <artifactId>blueprint-scripts</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId>
             <artifactId>processor-core</artifactId>
index b2991be..49a2c62 100644 (file)
@@ -21,6 +21,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintScriptsService
 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
 import org.slf4j.LoggerFactory
 import org.springframework.context.ApplicationContext
@@ -28,15 +29,14 @@ import org.springframework.stereotype.Service
 
 @Service
 class ComponentFunctionScriptingService(private val applicationContext: ApplicationContext,
-                                        private val bluePrintScriptsService: BluePrintScriptsService,
                                         private val blueprintJythonService: BlueprintJythonService) {
 
     private val log = LoggerFactory.getLogger(ComponentFunctionScriptingService::class.java)
 
     suspend fun <T : AbstractScriptComponentFunction> scriptInstance(componentFunction: AbstractComponentFunction,
-    scriptType: String,
-                                                             scriptClassReference: String,
-                                                             instanceDependencies: List<String>): T {
+                                                                     scriptType: String,
+                                                                     scriptClassReference: String,
+                                                                     instanceDependencies: List<String>): T {
 
         log.info("creating component function of script type($scriptType), reference name($scriptClassReference) and " +
                 "instanceDependencies($instanceDependencies)")
@@ -66,14 +66,16 @@ class ComponentFunctionScriptingService(private val applicationContext: Applicat
 
 
     suspend fun <T : BlueprintFunctionNode<*, *>> scriptInstance(bluePrintContext: BluePrintContext, scriptType: String,
-                                                         scriptClassReference: String): T {
+                                                                 scriptClassReference: String): T {
         var scriptComponent: T? = null
 
         when (scriptType) {
             BluePrintConstants.SCRIPT_INTERNAL -> {
+                val bluePrintScriptsService: BluePrintScriptsService = BluePrintScriptsServiceImpl()
                 scriptComponent = bluePrintScriptsService.scriptInstance<T>(scriptClassReference)
             }
             BluePrintConstants.SCRIPT_KOTLIN -> {
+                val bluePrintScriptsService: BluePrintScriptsService = BluePrintScriptsServiceImpl()
                 scriptComponent = bluePrintScriptsService.scriptInstance<T>(bluePrintContext, scriptClassReference, false)
             }
             BluePrintConstants.SCRIPT_JYTHON -> {
index 224319c..309db9d 100644 (file)
@@ -42,7 +42,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
 import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.cds.controllerblueprints.scripts.BluePrintScriptsServiceImpl
+import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintScriptsServiceImpl
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.test.context.ContextConfiguration
 import org.springframework.test.context.junit4.SpringRunner
index 9e22af6..d0710b2 100644 (file)
@@ -15,7 +15,8 @@
   ~ 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">
+<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">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
     <name>Controller Blueprints Core</name>
 
     <dependencies>
+        <!-- Compiler Service -->
+        <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>com.fasterxml.jackson.dataformat</groupId>
             <artifactId>jackson-dataformat-xml</artifactId>
index b822f00..18091e6 100644 (file)
@@ -84,7 +84,7 @@ fun normalizedFile(path: String, vararg more: String?): File {
 }
 
 fun normalizedPath(path: String, vararg more: String?): Path {
-    return Paths.get(path, *more).normalize().toAbsolutePath()
+    return Paths.get(path, *more).toAbsolutePath().normalize()
 }
 
 fun normalizedPathName(path: String, vararg more: String?): String {
  * limitations under the License.
  */
 
-package org.onap.ccsdk.cds.controllerblueprints.scripts
+package org.onap.ccsdk.cds.controllerblueprints.core.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,
index 60ed634..ef5cb81 100644 (file)
 package org.onap.ccsdk.cds.controllerblueprints.core.utils
 
 
-import org.slf4j.LoggerFactory
 import com.fasterxml.jackson.databind.JsonNode
 import kotlinx.coroutines.runBlocking
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.*
 import org.onap.ccsdk.cds.controllerblueprints.core.data.ToscaMetaData
-import org.onap.ccsdk.cds.controllerblueprints.core.normalizedFile
-import org.onap.ccsdk.cds.controllerblueprints.core.readNBLines
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintImportService
 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeService
 import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
+import org.slf4j.LoggerFactory
 import java.io.File
 import java.util.*
 
 class BluePrintMetadataUtils {
     companion object {
-        private val log= LoggerFactory.getLogger(this::class.toString())
+        private val log = LoggerFactory.getLogger(this::class.toString())
 
 
         suspend fun toscaMetaData(basePath: String): ToscaMetaData {
diff --git a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml
deleted file mode 100644 (file)
index 2f4b047..0000000
+++ /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>
index 3310c38..0a7e82c 100644 (file)
@@ -31,7 +31,6 @@
         <module>blueprint-core</module>
         <module>resource-dict</module>
         <module>db-resources</module>
-        <module>blueprint-scripts</module>
         <module>blueprint-validation</module>
         <module>service</module>
     </modules>
index 983e277..27babe1 100644 (file)
             <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
             <artifactId>blueprint-validation</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
-            <artifactId>blueprint-scripts</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.apache.velocity</groupId>
             <artifactId>velocity</artifactId>
index 3defd74..6ff76e9 100644 (file)
                 <artifactId>blueprint-validation</artifactId>
                 <version>${project.version}</version>
             </dependency>
-            <dependency>
-                <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
-                <artifactId>blueprint-scripts</artifactId>
-                <version>${project.version}</version>
-            </dependency>
             <dependency>
                 <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId>
                 <artifactId>service</artifactId>