blob: ec27cfa0ab0f01a0533b6aed434ff8f6a37f5da7 [file] [log] [blame]
William Kurkianbde6fc92018-07-13 17:19:58 -04001/*
William Kurkian1bedb412018-07-19 12:55:41 -04002* Copyright 2018- Cisco
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
William Kurkianbde6fc92018-07-13 17:19:58 -040016package config;
17
18import java.util.Properties;
19import java.io.FileInputStream;
20
21import org.slf4j.Logger;
22import org.slf4j.LoggerFactory;
23
24public class Config {
25
William Kurkian1bedb412018-07-19 12:55:41 -040026 private static Properties properties;
William Kurkianbde6fc92018-07-13 17:19:58 -040027
William Kurkian1bedb412018-07-19 12:55:41 -040028 private final static Logger logger = LoggerFactory.getLogger("VolthaKafkaConsumer");
William Kurkianbde6fc92018-07-13 17:19:58 -040029
William Kurkian1bedb412018-07-19 12:55:41 -040030 public static void loadProperties(String file) {
31 // create application properties with default
32 try {
33 properties = new Properties();
William Kurkianbde6fc92018-07-13 17:19:58 -040034
William Kurkian1bedb412018-07-19 12:55:41 -040035 // now load properties
36 // from last invocation
37 FileInputStream in = new FileInputStream(file);
38 properties.load(in);
39 in.close();
40 } catch (Exception e) {
41 logger.error(e.getMessage());
42 }
William Kurkianbde6fc92018-07-13 17:19:58 -040043 }
William Kurkianbde6fc92018-07-13 17:19:58 -040044
William Kurkian1bedb412018-07-19 12:55:41 -040045 public static String get(String key) {
46 return (String)properties.get(key);
47 }
William Kurkianbde6fc92018-07-13 17:19:58 -040048
William Kurkian1bedb412018-07-19 12:55:41 -040049 public static String getVesAddress() {
50 return get("onap_ves_address");
51 }
William Kurkianbde6fc92018-07-13 17:19:58 -040052
William Kurkian1bedb412018-07-19 12:55:41 -040053 public static String getVesPort() {
54 return get("onap_ves_port");
55 }
William Kurkianbde6fc92018-07-13 17:19:58 -040056
William Kurkian1bedb412018-07-19 12:55:41 -040057 public static String getKafkaAddress() {
58 return get("kafka_address");
59 }
William Kurkianbde6fc92018-07-13 17:19:58 -040060
William Kurkian1bedb412018-07-19 12:55:41 -040061 public static String getKafkaPort() {
62 return get("kafka_port");
63 }
William Kurkianbde6fc92018-07-13 17:19:58 -040064
William Kurkian1bedb412018-07-19 12:55:41 -040065 public static String getKafkaTopic() {
66 return get("kafka_topic");
67 }
William Kurkian7180b942018-08-15 15:26:17 -040068
69 public static String getCoId() {
70 return get("co_id");
71 }
72
73 public static String getPodId() {
74 return get("pod_id");
75 }
William Kurkianbde6fc92018-07-13 17:19:58 -040076}