public class OperationalDefaultsPreprocessor extends Object implements DocumentElementPreprocessor.ElementPreprocessor
OperationalDefaultsPreprocessor
is an DocumentElementPreprocessor.ElementPreprocessor
that introduces
(via cloning) default xml content for xml elements where the said content is missing.
Ultimately this DocumentElementPreprocessor.ElementPreprocessor
is designed to perform pre-processing of Coherence cache-config.xml
files to inject appropriate Operational Config elements defined separately in tangosol-coherence.*.xml files.
Constructor and Description |
---|
OperationalDefaultsPreprocessor()
Constructs a
OperationalDefaultsPreprocessor . |
Modifier and Type | Method and Description |
---|---|
void |
addDefaultsDefinition(String sPath,
XmlElement defaultsElement)
Defines that elements matching the specified path must contain the child elements defined by the default element.
|
boolean |
preprocess(ProcessingContext context,
XmlElement element)
Process an
XmlElement , optionally mutating it (or it's children) if required. |
public OperationalDefaultsPreprocessor()
OperationalDefaultsPreprocessor
.public boolean preprocess(ProcessingContext context, XmlElement element) throws ConfigurationException
XmlElement
, optionally mutating it (or it's children) if required.
Note: An implementation of this interface should avoid
attempting to traverse child XmlElement
s. If you wish to
manually traverse or change the entire document, you should instead use
a DocumentPreprocessor
.
preprocess
in interface DocumentElementPreprocessor.ElementPreprocessor
context
- the ProcessingContext
in which the pre-processing is occurringelement
- the XmlElement
to preprocesstrue
if the specified XmlElement
should be
re-preprocessed by this and other DocumentElementPreprocessor.ElementPreprocessor
s
due to the XmlElement
being modified, false
otherwise.ConfigurationException
- if during pre-processing of the XmlElement
a configuration
issue was discovered (or if pre-processing fails for some reason)public void addDefaultsDefinition(String sPath, XmlElement defaultsElement)
Paths used by this method are based those defined by the XmlHelper.findElement(XmlElement, String)
method, with the exception that ".." is not supported.
For example 1: The following specifies that the elements matching the absolute path "/caching-schemes/distributed-scheme" must contain the children defined by the xmlDistributedSchemeDefaults element. If not, they must be cloned into place.
addDefaultsDefinition("/caching-schemes/distributed-scheme", xmlDistributedSchemeDefaults);
For example 2: The following specifies that the elements matching the relative path "distributed-scheme" must contain the children defined by the xmlDistributedSchemeDefaults element. If not, they must be cloned into place.
addDefaultsDefinition("distributed-scheme", xmlDistributedSchemeDefaults);
sPath
- The path of elements requiring the defaultsdefaultsElement
- The xml element containing the required defaults for the specified path