|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openmobileis.common.util.PropertiesManager
Use to manage application properties. 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
Field Summary | |
java.util.Properties |
globalProperties
|
static PropertiesManager |
instance
|
Constructor Summary | |
protected |
PropertiesManager()
|
Method Summary | |
void |
addPropertiesFile(java.lang.String filename)
load a property file inside the classpath. |
void |
addPropertiesFileFromFilePath(java.lang.String filename)
load a property file from the file system If not found throw IOException |
void |
addProperty(java.lang.String key,
java.lang.String value)
add the specified key,value to the manager properties |
protected java.io.InputStream |
convertPropertiesFile(java.io.InputStream inStream)
|
static PropertiesManager |
getManager()
main method to get ResourceManager |
java.util.Properties |
getProperties()
return all the loaded properties |
java.util.Properties |
getProperties(java.lang.String prop_file)
read the property file inside the classpath. |
java.util.Properties |
getPropertiesFromPath(java.lang.String prop_file)
read the property file from the file system Does not load it |
java.lang.String |
getProperty(java.lang.String key)
return the property with specified key from loaded properties. |
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
return the property with specified key from loaded properties. |
java.io.InputStream |
getRessourceAsStream(java.lang.String name)
|
static void |
registerInstance(PropertiesManager manager)
Use to register another ResourceManager. |
void |
removeAllProperties()
remove all resource manager properties |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static PropertiesManager instance
public java.util.Properties globalProperties
Constructor Detail |
protected PropertiesManager()
Method Detail |
public void removeAllProperties()
public static PropertiesManager getManager()
public static void registerInstance(PropertiesManager manager)
manager
- : properties manager to registerpublic java.io.InputStream getRessourceAsStream(java.lang.String name) throws java.io.IOException
java.io.IOException
public void addPropertiesFile(java.lang.String filename) throws java.io.IOException
filename
- : properties file name.
java.io.IOException
- : throws if the file is not foundpublic void addPropertiesFileFromFilePath(java.lang.String filename) throws java.io.IOException
filename
- : properties file name.
java.io.IOException
- : throws if the file is not foundpublic java.util.Properties getProperties(java.lang.String prop_file) throws java.io.IOException
java.io.IOException
- : throws if the file is not foundpublic java.util.Properties getPropertiesFromPath(java.lang.String prop_file) throws java.io.IOException
java.io.IOException
- : throws if the file is not foundpublic java.util.Properties getProperties()
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
key
- : the property key to getdefaultValue
- : default value if key is not found
public java.lang.String getProperty(java.lang.String key)
key
- : the property key to get
public void addProperty(java.lang.String key, java.lang.String value)
key
- : the property keyvalue
- : value of the propertyprotected java.io.InputStream convertPropertiesFile(java.io.InputStream inStream) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |