DMAAP-MR - Merge MR repos
[dmaap/messagerouter/messageservice.git] / src / main / java / org / onap / dmaap / dmf / mr / CambriaApiVersionInfo.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  org.onap.dmaap
4  *  ================================================================================
5  *  Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  *  ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  *        http://www.apache.org/licenses/LICENSE-2.0
11 *  
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *  ============LICENSE_END=========================================================
18  *  
19  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
20  *  
21  *******************************************************************************/
22 package org.onap.dmaap.dmf.mr;
23
24 import com.att.eelf.configuration.EELFLogger;
25 import com.att.eelf.configuration.EELFManager;
26
27 import java.io.IOException;
28 import java.io.InputStream;
29 import java.util.Properties;
30
31 /**
32  * CambriaApiVersionInfo will provide the version of cambria code
33  * 
34  * @author peter
35  *
36  */
37 public class CambriaApiVersionInfo {
38     
39         /**
40          * 3 constants are defined:-
41          * PROPS,VERSION and LOG
42          */
43         
44         private static final Properties PROPS = new Properties();
45     private static final String VERSION;
46
47
48     private static final EELFLogger LOG = EELFManager.getInstance().getLogger(CambriaApiVersionInfo.class);
49     
50     /**
51      * private constructor created with no argument
52      * to avoid default constructor
53      */
54     private CambriaApiVersionInfo()
55     {
56         
57     }
58     
59     /**
60      * returns version of String type
61      */
62     public static String getVersion() {
63         return VERSION;
64     }
65
66     /** 
67      * 
68      * defines static initialization method
69      * It initializes VERSION Constant
70      * it handles exception in try catch block 
71      * and throws IOException
72      * 
73      */
74     
75     static {
76         String use = null;
77         try {
78             final InputStream is = CambriaApiVersionInfo.class
79                     .getResourceAsStream("/cambriaApiVersion.properties");
80             if (is != null) {
81                 PROPS.load(is);
82                 use = PROPS.getProperty("cambriaApiVersion", null);
83             }
84         } catch (IOException e) {
85             LOG.error("Failed due to IO EXception:"+e);
86         }
87         VERSION = use;
88     }
89 }