Open Kilda Java Documentation
AppConfig.java
Go to the documentation of this file.
1 /* Copyright 2017 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.northbound.config;
17 
18 import static com.sabre.oss.conf4j.spring.Conf4jSpringConstants.CONF4J_CONFIGURATION_VALUE_PROCESSORS;
19 import static java.util.Collections.singletonList;
20 
25 
26 import com.sabre.oss.conf4j.processor.ConfigurationValueProcessor;
27 import com.sabre.oss.conf4j.spring.annotation.ConfigurationType;
28 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
29 import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
30 import org.springframework.context.annotation.Bean;
31 import org.springframework.context.annotation.ComponentScan;
32 import org.springframework.context.annotation.Configuration;
33 import org.springframework.context.annotation.Import;
34 
35 import java.util.List;
36 
41 @Configuration
42 @EnableAutoConfiguration(exclude = {ErrorMvcAutoConfiguration.class})
43 @Import({WebConfig.class, SecurityConfig.class, SwaggerConfig.class,
45 @ComponentScan({
46  "org.openkilda.northbound.controller",
47  "org.openkilda.northbound.converter",
48  "org.openkilda.northbound.service",
49  "org.openkilda.northbound.utils"})
50 @ConfigurationType(name = "kafkaTopicsConfig", value = KafkaTopicsConfig.class)
51 @ConfigurationType(name = "kafkaGroupConfig", value = KafkaNorthboundConfig.class)
52 @ConfigurationType(EnvironmentConfig.class)
53 public class AppConfig {
54 
55  @Bean(CONF4J_CONFIGURATION_VALUE_PROCESSORS)
56  List<ConfigurationValueProcessor> configurationValueProcessors(EnvironmentConfig environmentConfig) {
57  String namingPrefix = environmentConfig.getNamingPrefix();
58  KafkaNamingStrategy namingStrategy = new KafkaNamingStrategy(namingPrefix != null ? namingPrefix : "");
59 
60  // Apply the environment prefix to Kafka topics and groups in the configuration.
61  return singletonList(new KafkaNamingForConfigurationValueProcessor(namingStrategy));
62  }
63 }
value
Definition: nodes.py:62
name
Definition: setup.py:24