Class OperationalDefaultsPreprocessor

java.lang.Object
com.tangosol.coherence.config.xml.preprocessor.OperationalDefaultsPreprocessor
All Implemented Interfaces:
DocumentElementPreprocessor.ElementPreprocessor

public class OperationalDefaultsPreprocessor extends Object implements DocumentElementPreprocessor.ElementPreprocessor
A 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.

Since:
Coherence 12.1.2
Author:
bo 2012.01.10
  • Constructor Details

  • Method Details

    • preprocess

      public boolean preprocess(ProcessingContext context, XmlElement element) throws ConfigurationException
      Process an XmlElement, optionally mutating it (or it's children) if required.

      Note: An implementation of this interface should avoid attempting to traverse child XmlElements. If you wish to manually traverse or change the entire document, you should instead use a DocumentPreprocessor.

      Specified by:
      preprocess in interface DocumentElementPreprocessor.ElementPreprocessor
      Parameters:
      context - the ProcessingContext in which the pre-processing is occurring
      element - the XmlElement to preprocess
      Returns:
      true if the specified XmlElement should be re-preprocessed by this and other DocumentElementPreprocessor.ElementPreprocessors due to the XmlElement being modified, false otherwise.
      Throws:
      ConfigurationException - if during pre-processing of the XmlElement a configuration issue was discovered (or if pre-processing fails for some reason)
    • addDefaultsDefinition

      public void addDefaultsDefinition(String sPath, XmlElement defaultsElement)
      Defines that elements matching the specified path must contain the child elements defined by the default element. If not the missing children must be cloned from the default element into the element matching the path during pre-processing.

      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);

      Parameters:
      sPath - The path of elements requiring the defaults
      defaultsElement - The xml element containing the required defaults for the specified path