|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object eu.planets_project.ifr.core.common.conf.ServiceConfig
public final class ServiceConfig
Factory for obtaining configuration parameters. Configuration files are "properties" files, stored in a common directory which is defined by the system property "eu.planets-project.config.dir" Generally, configuration is expected to be performed in a manner analogous to log4j. For example:
public class MyClass { private static Configuration config = ServiceConfig.getConfiguration(MyClass.class); public MyClass() { String value1 = config.getString("test.name"); int value2 = config.getInt("test.version"); } }The configuration will then be loaded from a file in the directory specified (above). The name of the configuration file will be the fully qualified class name suffixed with ".properties" The method
getConfiguration()
can alternatively accept a String type
parameter which allows the name of the configuration file to be more explicitly
specified. The name of the configuration file will be the value of the parameter
suffixed with ".properties" and will still be located in the directory specified
above.
If the property file does not exist, or cannot be parsed a
ConfigurationException
will be thrown. If a property is requested that cannot be found, a
NoSuchElementException
will be thrown.
Method Summary | |
---|---|
static Configuration |
getConfiguration(java.lang.Class<?> clazz)
Find the configuration file for a given class and return an object representing it. |
static Configuration |
getConfiguration(java.io.File properties)
Return a configuration based on the contents of the passed file |
static Configuration |
getConfiguration(java.lang.String basename)
Find a configuration file and return an object representing it. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Configuration getConfiguration(java.lang.Class<?> clazz) throws ConfigurationException
clazz
- Specifies the configuration file in question. The filename will
be the fully qualified class name suffixed with ".properties"
ConfigurationException
- If the appropriate file cannot be found or, if present,
parsed correctly.public static Configuration getConfiguration(java.lang.String basename) throws ConfigurationException
basename
- Specifies the configuration file in question. The filename will
be suffixed with ".properties"
ConfigurationException
- If the appropriate file cannot be found or, if present,
parsed correctly.public static Configuration getConfiguration(java.io.File properties)
properties
- the config file
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |