2 * Copyright 2016 [ZTE] and others.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.openo.carbon.bpel.config;
19 import java.io.FileNotFoundException;
20 import java.util.Properties;
22 import org.apache.commons.lang3.StringUtils;
23 import org.apache.log4j.Logger;
25 public abstract class AbstractBpsProperties {
26 private static final Logger dmsg = Logger.getLogger(AbstractBpsProperties.class.getName());
27 private Properties properties;
29 protected AbstractBpsProperties() {
30 properties = new Properties();
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); }
38 File propertyFile = new File(getConfigName());
40 if (propertyFile != null) {
41 properties.load(this.getClass().getResourceAsStream("/" + propertyFile.getName()));
43 } catch (FileNotFoundException e) {
44 dmsg.error(e.getMessage(), e);
45 } catch (Exception e) {
46 dmsg.error(e.getMessage(), e);
51 protected abstract String getConfigName();
53 public String getProperty(String propertyName) {
54 String value = properties.getProperty(propertyName);
55 return StringUtils.trimToEmpty(value);