public class VariableSubstitutionPreProcessor extends ConfigPreProcessorImpl
ConfigurationPreProcessor
implementation that supports variable substitution before
configuration is un-marshalled.
This ConfigurationPreProcessor can be activated by the setting or appending to the bootstrap property "preProcessors" to be variableSubstitution and making sure the required jars are available on the classpath.
The following properties can be specified in the bootstrap.properties to control the behaviour of the variable substitution;
Property | Default | Mandatory | Description |
---|---|---|---|
"variable-substitution.varprefix" | "${" | No | The value here will be prepended to the variable name to search for in the configuration to be switched out. |
"variable-substitution.varpostfix" | "}" | No | The value here will be appended to the variable name to search for in the configuration to be switched out. |
"variable-substitution.properties.url" | Yes | The URL to the property file containing the list of substitutions; in the form of variableName=Value. One substitution per line. Multiple property files are supported by specifying a unique suffix for each property file. | |
"variable-substitution.url.useHostname" | false | No | If true, Each URL defined by "variable-substitution.properties.url" will be formatted using
String#format(String, Object...) passing in the hostname as the parameter. |
"variable-substitution.impl" | SIMPLE | No | The substitution engine that will perform the variable substitution. defaults to SIMPLE
(Constants.DEFAULT_VAR_SUB_IMPL ). |
preProcessors=variableSubstitution
variable-substitution.properties.url.1=file://localhost//path/to/my/variables
variable-substitution.properties.url.2=file://localhost//path/to/my/variables.2
variable-substitution.properties.url.3=file://localhost//path/to/my/variables-%1$s
variable-substitution.url.useHostname=true
And .//path/to/my/variables.properties
/ /path/to/my/variables.2
/
/path/to/my/variables-localhost.localdomain
contains
broker.url=tcp://localhost:2506
broker.backup.url=tcp://my.host:2507
Then all instances of ${broker.url}
and ${broker.backup.url}
will be replaced within the adapter.xml as
it is read in, but before the Adapter itself is unmarshalled. A warning is logged if a file cannot be accessed.Constructor and Description |
---|
VariableSubstitutionPreProcessor(BootstrapProperties bootstrapProperties) |
VariableSubstitutionPreProcessor(KeyValuePairSet kvps) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
process(java.lang.String xml) |
java.lang.String |
process(java.net.URL urlToXml) |
getBootstrapProperties, getConfiguration, getProperties, setBootstrapProperties, setConfiguration, setProperties
public VariableSubstitutionPreProcessor(BootstrapProperties bootstrapProperties)
public VariableSubstitutionPreProcessor(KeyValuePairSet kvps)
public java.lang.String process(java.lang.String xml) throws CoreException
CoreException
public java.lang.String process(java.net.URL urlToXml) throws CoreException
CoreException