org.openmobileis.common.util.PropertiesManager Class Reference

Inheritance diagram for org.openmobileis.common.util.PropertiesManager:

org.openmobileis.common.util.PropertiesService

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 56 of file PropertiesManager.java.


Public Member Functions

void removeAllProperties ()
 remove all resource manager properties
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
void removeProperty (String key)
 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.

Member Function Documentation

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

main method to get ResourceManager

Returns:
application properties manager

Definition at line 77 of file PropertiesManager.java.

Referenced by org.openmobileis.common.util.PropertiesManager.registerInstance().

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 95 of file PropertiesManager.java.

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

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

Implements org.openmobileis.common.util.PropertiesService.

Definition at line 119 of file PropertiesManager.java.

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

Implements org.openmobileis.common.util.PropertiesService.

Definition at line 147 of file PropertiesManager.java.

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

Implements org.openmobileis.common.util.PropertiesService.

Definition at line 171 of file PropertiesManager.java.

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

Implements org.openmobileis.common.util.PropertiesService.

Definition at line 201 of file PropertiesManager.java.

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

return all the loaded properties

Returns:
the loaded properties

Implements org.openmobileis.common.util.PropertiesService.

Definition at line 225 of file PropertiesManager.java.

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.

Implements org.openmobileis.common.util.PropertiesService.

Definition at line 237 of file PropertiesManager.java.

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.

Implements org.openmobileis.common.util.PropertiesService.

Definition at line 248 of file PropertiesManager.java.

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

Implements org.openmobileis.common.util.PropertiesService.

Definition at line 258 of file PropertiesManager.java.

void org.openmobileis.common.util.PropertiesManager.removeProperty ( String  key  ) 

add the specified key,value to the manager properties

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

Definition at line 268 of file PropertiesManager.java.


The documentation for this class was generated from the following file:
Generated on Mon Jan 11 21:19:20 2010 for OpenMobileIS by  doxygen 1.5.4