Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

org.openmobileis.common.util.PropertiesManager Class Reference

List of all members.

Detailed Description

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

Author:
Philippe Delrieu
Since:
JDK 1.1
Version:
1.0

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


Member Function Documentation

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

Parameters:
filename : properties file name.
Exceptions:
IOException : throws if the file is not found

Definition at line 120 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

Parameters:
filename : properties file name.
Exceptions:
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.

void org.openmobileis.common.util.PropertiesManager.addProperty String  key,
String  value
 

add the specified key,value to the manager properties

Parameters:
key : the property key
value : value of the property

Definition at line 237 of file PropertiesManager.java.

References org.openmobileis.common.util.PropertiesManager.globalProperties.

static PropertiesManager org.openmobileis.common.util.PropertiesManager.getManager  )  [static]
 

main method to get ResourceManager

Returns:
application properties manager

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().

java.util.Properties org.openmobileis.common.util.PropertiesManager.getProperties  ) 
 

return all the loaded properties

Returns:
the loaded properties

Definition at line 204 of file PropertiesManager.java.

References 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

Parameters:
filename : properties file name.
Exceptions:
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

Parameters:
filename : properties file name.
Exceptions:
IOException : throws if the file is not found

Definition at line 187 of file PropertiesManager.java.

References org.openmobileis.common.util.PropertiesManager.convertPropertiesFile().

String org.openmobileis.common.util.PropertiesManager.getProperty String  key  ) 
 

return the property with specified key from loaded properties.

return null if not found.

Parameters:
key : the property key to get
Returns:
the property with specified key or null if not found.

Definition at line 227 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.

Parameters:
key : the property key to get
defaultValue : default value if key is not found
Returns:
the property with specified key or default value if not found.

Definition at line 216 of file PropertiesManager.java.

References org.openmobileis.common.util.PropertiesManager.globalProperties.

static void org.openmobileis.common.util.PropertiesManager.registerInstance PropertiesManager  manager  )  [static]
 

Use to register another ResourceManager.

Parameters:
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.


The documentation for this class was generated from the following file:
Generated on Wed Dec 14 21:05:37 2005 for OpenMobileIS by  doxygen 1.4.4