Application properties files should be stored in a folder called "properties" inside the classpath. Not mandatory but its a project practice. Otherwise the manager looks in the classpath for file properties
Implements singleton pattern. Use getManager method to get access to the application resource manager
Propertie file can contain fields that begin with $. These fields are replaced when loaded by system property first that PropertiesManager property For exemple if you define in the propery file the following property : if system user.dir is /home/application myproperty=$user.dir/somepath/file The property loaded will be myproperty=/home/application/somepath/file
Definition at line 55 of file PropertiesManager.java.
Public Member Functions | |
void | removeAllProperties () |
remove all resource manager properties | |
java.io.InputStream | getRessourceAsStream (String name) throws java.io.IOException |
void | addPropertiesFile (String filename) throws IOException |
load a property file inside the classpath. | |
void | addPropertiesFileFromFilePath (String filename) throws java.io.IOException |
load a property file from the file system If not found throw IOException | |
java.util.Properties | getProperties (String prop_file) throws java.io.IOException |
read the property file inside the classpath. | |
java.util.Properties | getPropertiesFromPath (String prop_file) throws java.io.IOException |
read the property file from the file system Does not load it | |
java.util.Properties | getProperties () |
return all the loaded properties | |
String | getProperty (String key, String defaultValue) |
return the property with specified key from loaded properties. | |
String | getProperty (String key) |
return the property with specified key from loaded properties. | |
void | addProperty (String key, String value) |
add the specified key,value to the manager properties | |
Static Public Member Functions | |
static PropertiesManager | getManager () |
main method to get ResourceManager | |
static void | registerInstance (PropertiesManager manager) |
Use to register another ResourceManager. | |
Public Attributes | |
Properties | globalProperties = new java.util.Properties() |
Static Public Attributes | |
static PropertiesManager | instance = null |
Protected Member Functions | |
PropertiesManager () | |
InputStream | convertPropertiesFile (InputStream inStream) throws java.io.IOException |
static PropertiesManager org.openmobileis.common.util.PropertiesManager.getManager | ( | ) | [static] |
main method to get ResourceManager
Definition at line 76 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.instance, and org.openmobileis.common.util.PropertiesManager.PropertiesManager().
Referenced by org.openmobileis.common.util.PropertiesManager.registerInstance().
static void org.openmobileis.common.util.PropertiesManager.registerInstance | ( | PropertiesManager | manager | ) | [static] |
Use to register another ResourceManager.
manager | : properties manager to register |
Definition at line 94 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.getManager(), and org.openmobileis.common.util.PropertiesManager.instance.
void org.openmobileis.common.util.PropertiesManager.addPropertiesFile | ( | String | filename | ) | throws IOException |
load a property file inside the classpath.
if the path is /org/openmobileis/file.properties First look in the classpath for /properties/org/openmobileis/file.properties then in /org/openmobileis/file.properties. If not found throw IOException
filename | : properties file name. |
IOException | : throws if the file is not found |
Definition at line 114 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.convertPropertiesFile(), and org.openmobileis.common.util.PropertiesManager.globalProperties.
void org.openmobileis.common.util.PropertiesManager.addPropertiesFileFromFilePath | ( | String | filename | ) | throws java.io.IOException |
load a property file from the file system If not found throw IOException
filename | : properties file name. |
IOException | : throws if the file is not found |
Definition at line 142 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.convertPropertiesFile(), and org.openmobileis.common.util.PropertiesManager.globalProperties.
java.util.Properties org.openmobileis.common.util.PropertiesManager.getProperties | ( | String | prop_file | ) | throws java.io.IOException |
read the property file inside the classpath.
Does not load it if the path is /org/openmobileis/file.properties First looks in the classpath for /properties/org/openmobileis/file.properties then for /org/openmobileis/file.properties. If not found throw IOException
filename | : properties file name. |
IOException | : throws if the file is not found |
Definition at line 163 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.convertPropertiesFile().
java.util.Properties org.openmobileis.common.util.PropertiesManager.getPropertiesFromPath | ( | String | prop_file | ) | throws java.io.IOException |
read the property file from the file system Does not load it
filename | : properties file name. |
IOException | : throws if the file is not found |
Definition at line 193 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.convertPropertiesFile().
java.util.Properties org.openmobileis.common.util.PropertiesManager.getProperties | ( | ) |
return all the loaded properties
Definition at line 210 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.globalProperties.
String org.openmobileis.common.util.PropertiesManager.getProperty | ( | String | key, | |
String | defaultValue | |||
) |
return the property with specified key from loaded properties.
return default value if not found.
key | : the property key to get | |
defaultValue | : default value if key is not found |
Definition at line 222 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.globalProperties.
String org.openmobileis.common.util.PropertiesManager.getProperty | ( | String | key | ) |
return the property with specified key from loaded properties.
return null if not found.
key | : the property key to get |
Definition at line 233 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.globalProperties.
void org.openmobileis.common.util.PropertiesManager.addProperty | ( | String | key, | |
String | value | |||
) |
add the specified key,value to the manager properties
key | : the property key | |
value | : value of the property |
Definition at line 243 of file PropertiesManager.java.
References org.openmobileis.common.util.PropertiesManager.globalProperties.