View Javadoc
1   /*
2    * Copyright 2011 The Kuali Foundation.
3    * 
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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.kuali.ole.select.testing;
17  
18  import org.springframework.core.io.ClassPathResource;
19  
20  import java.util.Enumeration;
21  import java.util.Properties;
22  
23  public class PropertyManager {
24      static PropertyManager propManager;
25      static Properties prop;
26  
27      public static PropertyManager getInstance() {
28          if (propManager == null) {
29              propManager = new PropertyManager();
30              propManager.loadProperties();
31          }
32          return propManager;
33      }
34  
35      public static String getProperty(String key) {
36          String value = prop.getProperty(key);
37          return value;
38      }
39  
40      private void loadProperties() {
41          ClassPathResource classPathResource = new ClassPathResource("org/kuali/ole/select/testing/webservice.properties");
42          prop = new Properties();
43          try {
44              prop.load(classPathResource.getInputStream());
45              Enumeration keys = prop.propertyNames();
46              while (keys.hasMoreElements()) {
47                  String key = (String) keys.nextElement();
48                  prop.put(key, prop.getProperty((String) key));
49              }
50          } catch (Exception e) {
51              e.printStackTrace();
52          }
53      }
54  }