Add Kafka Streams consumer service
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / commons / message-lib / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / message / BluePrintMessageLibConfiguration.kt
1 /*
2  *  Copyright © 2019 IBM.
3  *  Modifications Copyright © 2018-2019 AT&T Intellectual Property.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17
18 package org.onap.ccsdk.cds.blueprintsprocessor.message
19
20
21 import com.fasterxml.jackson.databind.JsonNode
22 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BluePrintMessageLibPropertyService
23 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageConsumerService
24 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageProducerService
25 import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
26 import org.springframework.boot.context.properties.EnableConfigurationProperties
27 import org.springframework.context.annotation.ComponentScan
28 import org.springframework.context.annotation.Configuration
29
30 @Configuration
31 @ComponentScan
32 @EnableConfigurationProperties
33 open class BluePrintMessageLibConfiguration
34
35 /**
36  * Exposed Dependency Service by this Message Lib Module
37  */
38 fun BluePrintDependencyService.messageLibPropertyService(): BluePrintMessageLibPropertyService =
39         instance(MessageLibConstants.SERVICE_BLUEPRINT_MESSAGE_LIB_PROPERTY)
40
41 /** Extension functions for message producer service **/
42 fun BluePrintDependencyService.messageProducerService(selector: String): BlueprintMessageProducerService {
43     return messageLibPropertyService().blueprintMessageProducerService(selector)
44 }
45
46
47 fun BluePrintDependencyService.messageProducerService(jsonNode: JsonNode): BlueprintMessageProducerService {
48     return messageLibPropertyService().blueprintMessageProducerService(jsonNode)
49 }
50
51 /** Extension functions for message consumer service **/
52 fun BluePrintDependencyService.messageConsumerService(selector: String): BlueprintMessageConsumerService {
53     return messageLibPropertyService().blueprintMessageConsumerService(selector)
54 }
55
56 fun BluePrintDependencyService.messageConsumerService(jsonNode: JsonNode): BlueprintMessageConsumerService {
57     return messageLibPropertyService().blueprintMessageConsumerService(jsonNode)
58 }
59
60 class MessageLibConstants {
61     companion object {
62         const val SERVICE_BLUEPRINT_MESSAGE_LIB_PROPERTY = "blueprint-message-lib-property-service"
63         const val PROPERTY_MESSAGE_CONSUMER_PREFIX = "blueprintsprocessor.messageconsumer."
64         const val PROPERTY_MESSAGE_PRODUCER_PREFIX = "blueprintsprocessor.messageproducer."
65         const val TYPE_KAFKA_BASIC_AUTH = "kafka-basic-auth"
66         const val TYPE_KAFKA_STREAMS_BASIC_AUTH = "kafka-streams-basic-auth"
67     }
68 }