Run stop.sh can not shutdown wso2 process
[vfc/nfvo/wfengine.git] / wso2bpel-ext / wso2bpel-core / wso2bpel-mgr / src / main / java / org / openo / carbon / bpel / config / AbstractBpsProperties.java
1 /**
2  * Copyright 2016 ZTE Corporation.
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  */
16 package org.openo.carbon.bpel.config;
17
18 import java.io.File;
19 import java.io.FileNotFoundException;
20 import java.util.Properties;
21
22 import org.apache.commons.lang3.StringUtils;
23 import org.apache.log4j.Logger;
24
25 public abstract class AbstractBpsProperties {
26   private static final Logger dmsg = Logger.getLogger(AbstractBpsProperties.class.getName());
27   private Properties properties;
28
29   protected AbstractBpsProperties() {
30     properties = new Properties();
31     /*
32      * URL commonConfigURL = AbstractBpsProperties.class.getResource(getConfigName()); if
33      * (commonConfigURL != null) { try { properties.load(new FileInputStream(new
34      * File(commonConfigURL.getFile()))); } catch (IOException e) { dmsg.error(e.getMessage(), e); }
35      * }
36      */
37
38     File propertyFile = new File(getConfigName());
39     try {
40       if (propertyFile != null) {
41         properties.load(this.getClass().getResourceAsStream("/" + propertyFile.getName()));
42       }
43     } catch (FileNotFoundException e) {
44       dmsg.error(e.getMessage(), e);
45     } catch (Exception e) {
46       dmsg.error(e.getMessage(), e);
47     }
48
49   }
50
51   protected abstract String getConfigName();
52
53   public String getProperty(String propertyName) {
54     String value = properties.getProperty(propertyName);
55     return StringUtils.trimToEmpty(value);
56   }
57 }