Renaming Files having BluePrint to have Blueprint
[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 import com.fasterxml.jackson.databind.JsonNode
21 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageLibPropertyService
22 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageConsumerService
23 import org.onap.ccsdk.cds.blueprintsprocessor.message.service.BlueprintMessageProducerService
24 import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintDependencyService
25 import org.springframework.boot.context.properties.EnableConfigurationProperties
26 import org.springframework.context.annotation.ComponentScan
27 import org.springframework.context.annotation.Configuration
28
29 @Configuration
30 @ComponentScan
31 @EnableConfigurationProperties
32 open class BlueprintMessageLibConfiguration
33
34 /**
35  * Exposed Dependency Service by this Message Lib Module
36  */
37 fun BlueprintDependencyService.messageLibPropertyService(): BlueprintMessageLibPropertyService =
38     instance(MessageLibConstants.SERVICE_BLUEPRINT_MESSAGE_LIB_PROPERTY)
39
40 /** Extension functions for message producer service **/
41 fun BlueprintDependencyService.messageProducerService(selector: String): BlueprintMessageProducerService {
42     return messageLibPropertyService().blueprintMessageProducerService(selector)
43 }
44
45 fun BlueprintDependencyService.messageProducerService(jsonNode: JsonNode): BlueprintMessageProducerService {
46     return messageLibPropertyService().blueprintMessageProducerService(jsonNode)
47 }
48
49 /** Extension functions for message consumer service **/
50 fun BlueprintDependencyService.messageConsumerService(selector: String): BlueprintMessageConsumerService {
51     return messageLibPropertyService().blueprintMessageConsumerService(selector)
52 }
53
54 fun BlueprintDependencyService.messageConsumerService(jsonNode: JsonNode): BlueprintMessageConsumerService {
55     return messageLibPropertyService().blueprintMessageConsumerService(jsonNode)
56 }
57
58 class MessageLibConstants {
59     companion object {
60
61         const val SERVICE_BLUEPRINT_MESSAGE_LIB_PROPERTY = "blueprint-message-lib-property-service"
62         const val PROPERTY_MESSAGE_CONSUMER_PREFIX = "blueprintsprocessor.messageconsumer."
63         const val PROPERTY_MESSAGE_PRODUCER_PREFIX = "blueprintsprocessor.messageproducer."
64         const val TYPE_KAFKA_BASIC_AUTH = "kafka-basic-auth"
65         const val TYPE_KAFKA_SCRAM_SSL_AUTH = "kafka-scram-ssl-auth"
66         const val TYPE_KAFKA_SSL_AUTH = "kafka-ssl-auth"
67         const val TYPE_KAFKA_STREAMS_BASIC_AUTH = "kafka-streams-basic-auth"
68         const val TYPE_KAFKA_STREAMS_SSL_AUTH = "kafka-streams-ssl-auth"
69         const val TYPE_KAFKA_STREAMS_SCRAM_SSL_AUTH = "kafka-streams-scram-ssl-auth"
70     }
71 }