Class OorianConfig
oorian.properties, with optional environment profile overrides.
File Location:
Place oorian.properties in your application's WEB-INF/ directory.
This is the standard Java web application convention for configuration files and keeps
properties outside the classpath root, allowing changes without rebuilding.
| Project Type | Source Location | Deploys To |
|---|---|---|
| NetBeans + Ant | web/WEB-INF/oorian.properties | WEB-INF/oorian.properties |
| Maven / Gradle | src/main/webapp/WEB-INF/oorian.properties | WEB-INF/oorian.properties |
For backward compatibility, if no file is found in WEB-INF/, the framework
falls back to loading from the classpath root (WEB-INF/classes/).
The configuration file is loaded automatically during application startup. If no
oorian.properties file is found, a warning is logged and the application
continues with an empty configuration. All getter methods return sensible defaults
when a key is not present.
Environment Profiles:
After loading the base oorian.properties, the framework loads a profile-specific
file (e.g., oorian-dev.properties) whose values override the base configuration.
The active profile is resolved in this order:
- Programmatic:
Application.setProfile(String)(must be called before)invalid reference
initialize() - System property:
-Doorian.profile=dev - Environment variable:
OORIAN_PROFILE=dev - Default:
"prod"
Usage:
// Static access from anywhere
String dbUrl = OorianConfig.get().getString("db.url");
// With default values
int port = OorianConfig.get().getInt("server.port", 8080);
boolean debug = OorianConfig.get().getBoolean("debug.enabled", false);
// Check the active profile
if (OorianConfig.get().isProfile("dev")) { ... }
Example oorian.properties:
db.url=jdbc:mysql://localhost:3306/myapp db.pool.size=10 debug.enabled=false
Example oorian-dev.properties (overrides):
db.url=jdbc:h2:mem:devdb debug.enabled=true
- Since:
- 2.1
- Version:
- 1.0
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default profile used when no profile is specified. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) Checks whether a key exists in the configuration.static OorianConfigget()Returns the singleton OorianConfig instance.Returns the name of the active configuration profile.booleangetBoolean(String key, boolean defaultValue) Returns the boolean value for the given key, or the default if not found.doubleReturns the double value for the given key, or the default if not found or not a valid double.intReturns the integer value for the given key, or the default if not found or not a valid integer.longReturns the long value for the given key, or the default if not found or not a valid long.intReturns the number of configuration properties currently loaded.Returns the string value for the given key, ornullif not found.Returns the string value for the given key, or the default if not found.booleanChecks whether the active profile matches the given name.
-
Field Details
-
DEFAULT_PROFILE
The default profile used when no profile is specified.- See Also:
-
-
Constructor Details
-
OorianConfig
public OorianConfig()Creates a new empty OorianConfig instance.
-
-
Method Details
-
get
Returns the singleton OorianConfig instance.- Returns:
- the configuration instance
-
getString
Returns the string value for the given key, ornullif not found.- Parameters:
key- the property key- Returns:
- the property value, or
null
-
getString
Returns the string value for the given key, or the default if not found.- Parameters:
key- the property keydefaultValue- the default value to return if the key is not found- Returns:
- the property value, or
defaultValue
-
getInt
Returns the integer value for the given key, or the default if not found or not a valid integer.- Parameters:
key- the property keydefaultValue- the default value- Returns:
- the integer property value, or
defaultValue
-
getLong
Returns the long value for the given key, or the default if not found or not a valid long.- Parameters:
key- the property keydefaultValue- the default value- Returns:
- the long property value, or
defaultValue
-
getDouble
Returns the double value for the given key, or the default if not found or not a valid double.- Parameters:
key- the property keydefaultValue- the default value- Returns:
- the double property value, or
defaultValue
-
getBoolean
Returns the boolean value for the given key, or the default if not found.Values of
"true","yes", and"1"(case-insensitive) are consideredtrue. All other values are consideredfalse.- Parameters:
key- the property keydefaultValue- the default value- Returns:
- the boolean property value, or
defaultValue
-
containsKey
Checks whether a key exists in the configuration.- Parameters:
key- the property key- Returns:
trueif the key exists,falseotherwise
-
getPropertyCount
public int getPropertyCount()Returns the number of configuration properties currently loaded.- Returns:
- the number of properties
-
getActiveProfile
Returns the name of the active configuration profile.- Returns:
- the active profile name (e.g., "dev", "staging", "prod")
-
isProfile
Checks whether the active profile matches the given name.The comparison is case-insensitive.
- Parameters:
name- the profile name to check- Returns:
trueif the active profile matches,falseotherwise
-