public class AppConfig extends Object implements Map<String,String>
environment.properties
, where environment
is a name of a deployment environment, such as "development",
"staging", "production", etc.
You can also provide a global file, properties from which will be loaded in all environments: global.properties
.
In all cases the files need to be on the classpath under directory/package /app_config
.
Environment-specific file will have an "environment" part of the file name match to an environment variable called "ACTIVE_ENV".
Such configuration is easy to achieve in Unix shell:
export ACTIVE_ENV=test
If environment variable ACTIVE_ENV
is missing, it defaults to "development".
You can also provide an environment as a system property active_env
. System property overrides environment
variable ACTIVE_ENV
Constructor and Description |
---|
AppConfig() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<String,String>> |
entrySet() |
String |
get(Object key) |
static Map<String,String> |
getAllProperties() |
static Property |
getAsProperty(String key)
Returns property instance corresponding to key.
|
static String |
getProperty(String key)
Returns property value for a key.
|
static void |
init() |
boolean |
isEmpty() |
Set<String> |
keySet() |
static String |
p(String key)
Gets property, synonym for
getProperty(String) . |
String |
put(String key,
String value) |
void |
putAll(Map<? extends String,? extends String> m) |
String |
remove(Object key) |
int |
size() |
Collection<String> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
public static void init()
public static Property getAsProperty(String key)
key
- key for property.public static String getProperty(String key)
key
- key of property.null
if not found.public static String p(String key)
getProperty(String)
.key
- key of propertypublic boolean containsKey(Object key)
containsKey
in interface Map<String,String>
public boolean containsValue(Object value)
containsValue
in interface Map<String,String>
Copyright © 2016 JavaLite. All rights reserved.