public final class ParameterBuilder extends AbstractResourceBuilder<ParameterItem<?>,ParameterParams,Object> implements ParameterMessages
| Modifier and Type | Field and Description |
|---|---|
private String |
configurationFileExtension
The file extension used by configuration files.
|
private String |
configurationFileWildcard
The Wildcard used to load configuration files.
|
private static Pattern |
ENV_VAR_PATTERN1
The pattern that matches Environment Variable ${varname} .
|
private static Pattern |
ENV_VAR_PATTERN2
The pattern that matches Environment Variable $varname .
|
private static JRLogger |
LOGGER
The class logger.
|
private Map<ParameterItem<?>,Object> |
overriddenParametersMap
Store all overridden values defined by the call of define method.
|
private Map<String,ParameterEntry> |
propertiesParametersMap
Store all parameter values defined into properties files.
|
private Map<String,String> |
varenvMap
Store all translated environment variable.
|
CONF_READING_ERROR, CONFIG_FOUND, READ_CONF_FILE, SKIP_CONF_LOADING, STORE_PARAMETER, UNDEFINED_ENV_VAR, UPDATE_PARAMETER| Constructor and Description |
|---|
ParameterBuilder() |
| Modifier and Type | Method and Description |
|---|---|
protected Object |
buildResource(ParameterItem<?> parameterItem,
ParameterParams parameterParams)
Build the resource requested.
|
private String |
checkPattern(String value,
Pattern pattern,
boolean withBrace)
Check if the given string contains an environment variable.
|
void |
define(ParameterItem<?> key,
Object forcedValue)
Override a parameter value.
|
private void |
readPropertiesFile(String custConfFileName)
Read a customized configuration file to load parameters values.
|
private void |
readPropertiesFiles()
Read all configuration files available into the application classpath.
|
private String |
resolveVarEnv(String entryValue)
Resolve any environment variable found into the string.
|
void |
searchConfigurationFiles(String wildcard,
String extension)
Search configuration files according to the parameters provided.
|
private void |
storePropertiesParameter(Map.Entry<Object,Object> entry)
Store a parameter read from properties files.
|
get, getParam, getParamKey, set, storeParamsprivate static final JRLogger LOGGER
private static final Pattern ENV_VAR_PATTERN1
private static final Pattern ENV_VAR_PATTERN2
private final Map<String,ParameterEntry> propertiesParametersMap
private final Map<ParameterItem<?>,Object> overriddenParametersMap
private String configurationFileExtension
private String configurationFileWildcard
public void searchConfigurationFiles(String wildcard, String extension)
wildcard - the regex wildcard (must not be null)extension - the file extension without the first dot (ie: properties) (must not be null)private void readPropertiesFiles()
private void readPropertiesFile(String custConfFileName)
custConfFileName - the file to loadprivate void storePropertiesParameter(Map.Entry<Object,Object> entry)
entry - the entry to storeprivate String resolveVarEnv(String entryValue)
entryValue - the string to check and resolveprivate String checkPattern(String value, Pattern pattern, boolean withBrace)
value - the string value to parsepattern - the regex pattern to usewithBrace - true for ${varname}, false for $varnameprotected Object buildResource(ParameterItem<?> parameterItem, ParameterParams parameterParams)
buildResource in class AbstractResourceBuilder<ParameterItem<?>,ParameterParams,Object>parameterItem - the parameter item used to identify the resource elementparameterParams - the primitive parameters used to build the resourcepublic void define(ParameterItem<?> key, Object forcedValue)
key - the parameter item keyforcedValue - the overridden valueCopyright © 2011–2014 JRebirth OSS. All rights reserved.