Package org.opencms.configuration.test
Class CmsJaxbConfigHelper<T>
java.lang.Object
org.opencms.configuration.test.CmsJaxbConfigHelper<T>
- Type Parameters:
T
- the bean type to convert to/from XML
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
(Consumer<T> beanCallback) Gets a rule which uses JAXB to unmarshal a bean from the XML.
-
Constructor Details
-
CmsJaxbConfigHelper
Creates a new instance.- Parameters:
cls
- the bean class
-
-
Method Details
-
appendToXml
Appends the XML element for the bean to the given parent element.- Parameters:
parent
- the parent elementbean
- the bean to convert to an XML element and append to the parent
-
getDigesterRule
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
-