Class CmsJaxbConfigHelper<T>

  • Type Parameters:
    T - the bean type to convert to/from XML

    public class CmsJaxbConfigHelper<T>
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      CmsJaxbConfigHelper​(java.lang.Class<T> cls)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendToXml​(org.dom4j.Element parent, T bean)
      Appends the XML element for the bean to the given parent element.
      org.apache.commons.digester3.Rule getDigesterRule​(java.util.function.Consumer<T> beanCallback)
      Gets a rule which uses JAXB to unmarshal a bean from the XML.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CmsJaxbConfigHelper

        public CmsJaxbConfigHelper​(java.lang.Class<T> cls)
        Creates a new instance.
        Parameters:
        cls - the bean class
    • Method Detail

      • 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​(java.util.function.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