aboutsummaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/blueprint-core
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-03-27 13:22:51 -0400
committerMuthuramalingam, Brinda Santh <brindasanth@in.ibm.com>2019-04-01 10:43:53 -0400
commit40072d3dcc1d0193bba1ea9432c13ac24857be55 (patch)
tree2fe78015e772c4cbab4fd52184530b9e52c8c3af /ms/controllerblueprints/modules/blueprint-core
parent38300292cbce3bb0500593f3cc44fe129cf5c877 (diff)
Improve function interfaces
Change-Id: I24f45d39ac05491a4217101e00bcbf8d122e4e1a Issue-ID: CCSDK-1137 Signed-off-by: Muthuramalingam, Brinda Santh <brindasanth@in.ibm.com>
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-core')
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt4
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt42
2 files changed, 40 insertions, 6 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt
index 6db872062..8bb0cd0ce 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BluePrintScriptsService.kt
@@ -21,8 +21,8 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
interface BluePrintScriptsService {
- fun <T> scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String,
+ suspend fun <T> scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String,
reCompile: Boolean): T
- fun <T> scriptInstance(scriptClassName: String): T
+ suspend fun <T> scriptInstance(scriptClassName: String): T
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt
index a74adf970..932b9a09f 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt
@@ -1,5 +1,6 @@
/*
* 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.
@@ -16,6 +17,7 @@
package org.onap.ccsdk.cds.controllerblueprints.core.interfaces
+import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import java.util.function.Function
@@ -25,15 +27,47 @@ interface BlueprintFunctionNode<T, R> : Function<T, R> {
fun getName(): String
@Throws(BluePrintProcessorException::class)
- fun prepareRequest(executionRequest: T): T
+ fun prepareRequest(executionRequest: T): T = runBlocking {
+ prepareRequestNB(executionRequest)
+ }
@Throws(BluePrintProcessorException::class)
- fun process(executionRequest: T)
+ fun process(executionRequest: T) = runBlocking {
+ processNB(executionRequest)
+ }
@Throws(BluePrintProcessorException::class)
- fun recover(runtimeException: RuntimeException, executionRequest: T)
+ fun recover(runtimeException: RuntimeException, executionRequest: T) = runBlocking {
+ recoverNB(runtimeException, executionRequest)
+ }
@Throws(BluePrintProcessorException::class)
- fun prepareResponse(): R
+ fun prepareResponse(): R = runBlocking {
+ prepareResponseNB()
+ }
+ override fun apply(executionServiceInput: T): R {
+ try {
+ prepareRequest(executionServiceInput)
+ process(executionServiceInput)
+ } catch (runtimeException: RuntimeException) {
+ recover(runtimeException, executionServiceInput)
+ }
+ return prepareResponse()
+ }
+
+ @Throws(BluePrintProcessorException::class)
+ suspend fun prepareRequestNB(executionRequest: T): T
+
+ @Throws(BluePrintProcessorException::class)
+ suspend fun processNB(executionRequest: T)
+
+ @Throws(BluePrintProcessorException::class)
+ suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: T)
+
+ @Throws(BluePrintProcessorException::class)
+ suspend fun prepareResponseNB(): R
+
+ @Throws(BluePrintProcessorException::class)
+ suspend fun applyNB(t: T): R
} \ No newline at end of file