public class CacheDefaultsPreprocessor extends Object implements DocumentElementPreprocessor.ElementPreprocessor
CacheDefaultsPreprocessor
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 <defaults>
declarations, inserting them into the appropriate places in cache-config.xml documents.
OperationalDefaultsPreprocessor
Constructor and Description |
---|
CacheDefaultsPreprocessor(String sDefaultsParentPath)
Constructs a
CacheDefaultsPreprocessor with a specific path to where default element content can be located. |
Modifier and Type | Method and Description |
---|---|
void |
addDefaultDefinition(String sRequiredElementParentPath,
String sRequiredElementName)
Adds a requirement that the specified "default" element must be added to (if not already defined) in the element
specified by the defined parent path.
|
boolean |
preprocess(ProcessingContext context,
XmlElement element)
Process an
XmlElement , optionally mutating it (or it's children) if required. |
public CacheDefaultsPreprocessor(String sDefaultsParentPath)
CacheDefaultsPreprocessor
with a specific path to where default element content can be located.
Example: new DefaultPreprocessor("/defaults");
sDefaultsParentPath
- the absolute path to the XmlElement
that contains (is the parent of)
the default elementspublic 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 addDefaultDefinition(String sRequiredElementParentPath, String sRequiredElementName)
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 call specifies that the "serializer" should be cloned from the defined default path if it doesn't exist in the "/caching-schemes/distributed-scheme" element.
addDefaultDefinition("/caching-schemes/distributed-scheme", "serializer");
For example 2: The following call specifies that the "serializer" should be cloned from the defined default path if it doesn't exist in any "distributed-scheme" elements
addDefaultDefinition("distributed-scheme", "serializer");
sRequiredElementParentPath
- the path of the parent for the required elementsRequiredElementName
- the name of the element that should be cloned (if it doesn't exist in the
specified parent path) from the defined default element path