af097c35b86d1ec0b222a59126c97f77ad95338b
[transportpce.git] / nbinotifications / src / main / java / org / opendaylight / transportpce / nbinotifications / utils / NbiNotificationsUtils.java
1 /*
2  * Copyright © 2020 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.nbinotifications.utils;
9
10 import java.io.IOException;
11 import java.io.InputStream;
12 import java.util.Properties;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 public final class NbiNotificationsUtils {
17
18     private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsUtils.class);
19
20     private NbiNotificationsUtils() {
21     }
22
23     public static Properties loadProperties(String propertyFileName) {
24         Properties props = new Properties();
25         InputStream inputStream = NbiNotificationsUtils.class.getClassLoader().getResourceAsStream(propertyFileName);
26         try {
27             if (inputStream != null) {
28                 props.load(inputStream);
29             } else {
30                 LOG.warn("Kafka property file '{}' is empty", propertyFileName);
31             }
32         } catch (IOException e) {
33             LOG.error("Kafka property file '{}' was not found in the classpath", propertyFileName, e);
34         }
35         return props;
36     }
37 }