Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 22 23 28 29 package org.xquark.mapper.util; 30 31 import java.io.IOException ; 32 import java.io.InputStream ; 33 import java.util.Properties ; 34 35 import org.xquark.mapper.AccessManager; 36 import org.xquark.mapper.metadata.RepositoryConstants; 37 38 44 public class RepositoryProperties implements RepositoryConstants 45 { 46 private static final String RCSRevision = "$Revision: 1.1 $"; 47 private static final String RCSName = "$Name: $"; 48 49 private static Properties properties = null; 50 51 static 52 { 53 load(); 54 } 55 56 57 private RepositoryProperties() {} 58 59 public static String getStringProperty(String prop) 60 { 61 if (properties == null) 62 return null; 63 return properties.getProperty(prop); 64 } 65 public static int getIntProperty(String prop) 66 { 67 if (properties == null) 68 return -1; 69 return Integer.parseInt(properties.getProperty(prop)); 70 } 71 72 public static boolean getBooleanProperty(String prop) 73 { 74 if (properties == null) 75 return false; 76 return Boolean.valueOf(properties.getProperty(prop)).booleanValue(); 77 } 78 79 public static void load() 80 { 81 Properties defaultProperties = null; 82 if (properties != null) 83 return; 84 try { 85 defaultProperties = new Properties (); 86 defaultProperties.load(AccessManager.class.getResourceAsStream( 87 RESOURCES_FOLDER + DEFAULT_CONF_FILE)); 88 properties = new Properties (defaultProperties); 89 } 90 catch (IOException e) { 91 throw new RuntimeException ("Default configuration file couldn't be opened:" + e.getMessage()); 92 } 93 try { 94 InputStream inStream = AccessManager.class.getResourceAsStream("/" + CONF_FILE); if (inStream == null) inStream = AccessManager.class.getResourceAsStream(CONF_PACKAGE + CONF_FILE); if (inStream == null) inStream = AccessManager.class.getResourceAsStream(RESOURCES_FOLDER + DEFAULT_CONF_FILE); 99 if (inStream == null) 100 properties = defaultProperties; 101 else 102 properties.load(inStream); 103 } 104 catch (IOException e) { 105 throw new RuntimeException ("Default configuration file couldn't be opened:" + e.getMessage()); 106 } 107 } 108 } 109
| Popular Tags
|