Class CmsJaxbConfigHelper<T>

java.lang.Object
org.opencms.configuration.test.CmsJaxbConfigHelper<T>
Type Parameters:
T - the bean type to convert to/from XML

public class CmsJaxbConfigHelper<T> extends Object
Helper class for using JAXB to convert between beans and OpenCms config file XML elements.

To use this, first create a JAXB-compatible bean type with the correct annotations, then create an instance of this class as a member in the OpenCms configuration class (e.g.CmsSystemConfiguration.. Add the rule returned by getDigesterRule in the config object's addXmlDigesterRules, and call the appendToXml rule in the config object's generateXml method.

  • Constructor Details

  • Method Details

    • appendToXml

      public void appendToXml(org.dom4j.Element parent, T bean)
      Appends the XML element for the bean to the given parent element.
      Parameters:
      parent - the parent element
      bean - the bean to convert to an XML element and append to the parent
    • getDigesterRule

      public org.apache.commons.digester3.Rule getDigesterRule(Consumer<T> beanCallback)
      Gets a rule which uses JAXB to unmarshal a bean from the XML.
      Parameters:
      beanCallback - the callback to call with the finished bean
      Returns:
      the digester rule