From 86242e35b19d81bc2d6aa377928830aed2cf3ba3 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 27 Aug 2018 22:51:18 +0000 Subject: Blueprints Processor Service Add component factory for resource resolution component and resource resolution processor factory framework for input and default sources. Change-Id: Id2eb81454439857a1c252012d883661cb9b3d069 Issue-ID: CCSDK-411 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../core/factory/ComponentNodeFactory.kt | 61 ++++++++++++++++++++++ .../factory/ResourceAssignmentProcessorFactory.kt | 47 +++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt create mode 100644 ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt (limited to 'ms/blueprintsprocessor/modules/commons') diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt new file mode 100644 index 00000000..f42613cc --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt @@ -0,0 +1,61 @@ +/* + * 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.apps.blueprintsprocessor.core.factory + +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.context.ApplicationContext +import org.springframework.context.ApplicationContextAware +import org.springframework.stereotype.Service + +interface ComponentNode { + + @Throws(BluePrintProcessorException::class) + fun validate(context: MutableMap, componentContext: MutableMap) + + @Throws(BluePrintProcessorException::class) + fun process(context: MutableMap, componentContext: MutableMap) + + @Throws(BluePrintProcessorException::class) + fun errorHandle(context: MutableMap, componentContext: MutableMap) + + @Throws(BluePrintProcessorException::class) + fun reTrigger(context: MutableMap, componentContext: MutableMap) +} + +@Service +class ComponentNodeFactory : ApplicationContextAware { + private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java) + + var componentNodes: MutableMap = hashMapOf() + + fun getInstance(instanceName: String): ComponentNode? { + log.trace("looking for Component Nodes : {}", instanceName) + return componentNodes.get(instanceName) + } + + fun injectInstance(instanceName: String, componentNode: ComponentNode) { + this.componentNodes[instanceName] = componentNode + } + + override fun setApplicationContext(context: ApplicationContext) { + componentNodes = context.getBeansOfType(ComponentNode::class.java) + log.info("Injected Component Nodes : {}", componentNodes) + } +} \ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt new file mode 100644 index 00000000..8104c104 --- /dev/null +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt @@ -0,0 +1,47 @@ +/* + * 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.apps.blueprintsprocessor.core.factory + +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import org.springframework.context.ApplicationContext +import org.springframework.context.ApplicationContextAware +import org.springframework.stereotype.Service + +@Service +class ResourceAssignmentProcessorFactory : ApplicationContextAware { + + private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java) + + var resourceAssignmentProcessors: MutableMap = hashMapOf() + + fun getInstance(instanceName: String): ResourceAssignmentProcessor? { + log.trace("looking for Resource Assignment Processor : {}", instanceName) + return resourceAssignmentProcessors.get(instanceName) + } + + fun injectInstance(instanceName: String, resourceAssignmentProcessor: ResourceAssignmentProcessor) { + this.resourceAssignmentProcessors[instanceName] = resourceAssignmentProcessor + } + + override fun setApplicationContext(context: ApplicationContext) { + resourceAssignmentProcessors = context.getBeansOfType(ResourceAssignmentProcessor::class.java) + log.info("Injected Resource Assignment Processor : {}", resourceAssignmentProcessors) + } +} \ No newline at end of file -- cgit 1.2.3-korg