diff options
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts')
-rw-r--r-- | ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt (renamed from ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompileService.kt) | 20 | ||||
-rw-r--r-- | ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt (renamed from ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompilerCache.kt) | 18 | ||||
-rw-r--r-- | ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt (renamed from ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptsServiceImpl.kt) | 28 |
3 files changed, 33 insertions, 33 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompileService.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt index 5cf0a93af..230097f3c 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompileService.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompileService.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.config.Services -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.checkFileExists import org.onap.ccsdk.cds.controllerblueprints.core.logger import java.io.File @@ -40,9 +40,9 @@ import kotlin.script.experimental.api.SourceCode import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty import kotlin.system.measureTimeMillis -open class BlueprintCompileService { +open class BluePrintCompileService { - val log = logger(BlueprintCompileService::class) + val log = logger(BluePrintCompileService::class) companion object { @@ -55,7 +55,7 @@ open class BlueprintCompileService { /** Compile the [bluePrintSourceCode] and get the [kClassName] instance for the constructor [args] */ suspend fun <T> eval( - bluePrintSourceCode: BlueprintSourceCode, + bluePrintSourceCode: BluePrintSourceCode, kClassName: String, args: ArrayList<Any?>? ): T { @@ -68,14 +68,14 @@ open class BlueprintCompileService { } } - val classLoaderWithDependencies = BlueprintCompileCache.classLoader(bluePrintSourceCode.cacheKey) + val classLoaderWithDependencies = BluePrintCompileCache.classLoader(bluePrintSourceCode.cacheKey) /** Create the instance from the class loader */ return instance(classLoaderWithDependencies, kClassName, args) } /** Compile [bluePrintSourceCode] and put into cache */ - suspend fun compile(bluePrintSourceCode: BlueprintSourceCode) { + suspend fun compile(bluePrintSourceCode: BluePrintSourceCode) { // TODO("Include Multiple folders") val sourcePath = bluePrintSourceCode.blueprintKotlinSources.first() val compiledJarFile = bluePrintSourceCode.targetJarFile @@ -110,7 +110,7 @@ open class BlueprintCompileService { checkFileExists(compiledJarFile) { "couldn't generate compiled jar(${compiledJarFile.absolutePath})" } } else -> { - throw BlueprintException("$exitCode :${messageCollector.errors().joinToString("\n")}") + throw BluePrintException("$exitCode :${messageCollector.errors().joinToString("\n")}") } } } @@ -123,21 +123,21 @@ open class BlueprintCompileService { /** create class [kClassName] instance from [classLoader] */ fun <T> instance(classLoader: URLClassLoader, kClassName: String, args: ArrayList<Any?>? = arrayListOf()): T { val kClazz = classLoader.loadClass(kClassName) - ?: throw BlueprintException("failed to load class($kClassName) from current class loader.") + ?: throw BluePrintException("failed to load class($kClassName) from current class loader.") val instance = if (args.isNullOrEmpty()) { kClazz.newInstance() } else { kClazz.constructors .single().newInstance(*args.toArray()) - } ?: throw BlueprintException("failed to create class($kClassName) instance for constructor argument($args).") + } ?: throw BluePrintException("failed to create class($kClassName) instance for constructor argument($args).") return instance as T } } /** Compile source code information */ -open class BlueprintSourceCode : SourceCode { +open class BluePrintSourceCode : SourceCode { lateinit var blueprintKotlinSources: MutableList<String> lateinit var moduleName: String diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompilerCache.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt index a6d4571a2..a0efc619c 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintCompilerCache.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt @@ -19,18 +19,18 @@ package org.onap.ccsdk.cds.controllerblueprints.core.scripts import com.google.common.cache.CacheBuilder import com.google.common.cache.CacheLoader import com.google.common.cache.LoadingCache -import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintException +import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException import org.onap.ccsdk.cds.controllerblueprints.core.logger -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintFileUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import java.net.URLClassLoader -object BlueprintCompileCache { +object BluePrintCompileCache { - val log = logger(BlueprintCompileCache::class) + val log = logger(BluePrintCompileCache::class) private val classLoaderCache: LoadingCache<String, URLClassLoader> = CacheBuilder.newBuilder() .maximumSize(50) - .build(BlueprintClassLoader) + .build(BluePrintClassLoader) fun classLoader(key: String): URLClassLoader { return classLoaderCache.get(key) @@ -54,14 +54,14 @@ object BlueprintCompileCache { } } -object BlueprintClassLoader : CacheLoader<String, URLClassLoader>() { +object BluePrintClassLoader : CacheLoader<String, URLClassLoader>() { - val log = logger(BlueprintClassLoader::class) + val log = logger(BluePrintClassLoader::class) override fun load(key: String) = try { log.info("loading compiled cache($key)") - BlueprintFileUtils.getURLClassLoaderFromDirectory(key) + BluePrintFileUtils.getURLClassLoaderFromDirectory(key) } catch (e: Exception) { - throw BlueprintException("failed to load cache($key) with Exception($e)") + throw BluePrintException("failed to load cache($key) with Exception($e)") } } diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptsServiceImpl.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt index c89d74dfb..f3eb1a2b9 100644 --- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BlueprintScriptsServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptsServiceImpl.kt @@ -17,20 +17,20 @@ 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.BluePrintConstants +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintScriptsService import org.onap.ccsdk.cds.controllerblueprints.core.logger import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPathName -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintFileUtils -import org.onap.ccsdk.cds.controllerblueprints.core.utils.BlueprintMetadataUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils import java.util.ArrayList -open class BlueprintScriptsServiceImpl : BlueprintScriptsService { +open class BluePrintScriptsServiceImpl : BluePrintScriptsService { - val log = logger(BlueprintScriptsServiceImpl::class) + val log = logger(BluePrintScriptsServiceImpl::class) - override suspend fun <T> scriptInstance(bluePrintSourceCode: BlueprintSourceCode, scriptClassName: String): T { - val bluePrintCompileService = BlueprintCompileService() + override suspend fun <T> scriptInstance(bluePrintSourceCode: BluePrintSourceCode, scriptClassName: String): T { + val bluePrintCompileService = BluePrintCompileService() return bluePrintCompileService.eval(bluePrintSourceCode, scriptClassName, null) } @@ -43,13 +43,13 @@ open class BlueprintScriptsServiceImpl : BlueprintScriptsService { ): T { val sources: MutableList<String> = arrayListOf() - sources.add(normalizedPathName(blueprintBasePath, BlueprintConstants.TOSCA_SCRIPTS_KOTLIN_DIR)) + sources.add(normalizedPathName(blueprintBasePath, BluePrintConstants.TOSCA_SCRIPTS_KOTLIN_DIR)) - val scriptSource = BlueprintSourceCode() + val scriptSource = BluePrintSourceCode() scriptSource.blueprintKotlinSources = sources scriptSource.moduleName = "$artifactName-$artifactVersion-cba-kts" - scriptSource.cacheKey = BlueprintFileUtils.compileCacheKey(blueprintBasePath) - scriptSource.targetJarFile = BlueprintFileUtils.compileJarFile(blueprintBasePath, artifactName, artifactVersion) + scriptSource.cacheKey = BluePrintFileUtils.compileCacheKey(blueprintBasePath) + scriptSource.targetJarFile = BluePrintFileUtils.compileJarFile(blueprintBasePath, artifactName, artifactVersion) scriptSource.regenerate = reCompile return scriptInstance(scriptSource, scriptClassName) } @@ -59,7 +59,7 @@ open class BlueprintScriptsServiceImpl : BlueprintScriptsService { scriptClassName: String, reCompile: Boolean ): T { - val toscaMetaData = BlueprintMetadataUtils.toscaMetaData(blueprintBasePath) + val toscaMetaData = BluePrintMetadataUtils.toscaMetaData(blueprintBasePath) checkNotNull(toscaMetaData.templateName) { "couldn't find 'Template-Name' key in TOSCA.meta" } checkNotNull(toscaMetaData.templateVersion) { "couldn't find 'Template-Version' key in TOSCA.meta" } return scriptInstance( @@ -70,7 +70,7 @@ open class BlueprintScriptsServiceImpl : BlueprintScriptsService { override suspend fun <T> scriptInstance(cacheKey: String, scriptClassName: String): T { val args = ArrayList<Any?>() - return BlueprintCompileCache.classLoader(cacheKey).loadClass(scriptClassName).constructors + return BluePrintCompileCache.classLoader(cacheKey).loadClass(scriptClassName).constructors .single().newInstance(*args.toArray()) as T } |