JaxbService
Allows instances of JAXB-annotated classes to be marshalled to XML and unmarshalled from XML back into domain objects.
The default implementation automatically caches the JAXB marshallers by target class.
API
interface JaxbService {
Object fromXml(JAXBContext jaxbContext, String xml) (1)
Object fromXml(JAXBContext jaxbContext, String xml, Map<String, Object> unmarshallerProperties) (2)
T fromXml(Class<T> domainClass, String xml) (3)
T fromXml(Class<T> domainClass, String xml, Map<String, Object> unmarshallerProperties) (4)
String toXml(Object domainObject) (5)
String toXml(Object domainObject, Map<String, Object> marshallerProperties) (6)
Map<String, String> toXsd(Object domainObject, IsisSchemas isisSchemas) (7)
}
1 | fromXml(JAXBContext, String)
unmarshalls the XML into an instance of the class, using the provided JAXBContext . |
2 | fromXml(JAXBContext, String, Map)
unmarshalls the XML into an instance of the class, using the provided JAXBContext and the additional properties. |
3 | fromXml(Class, String)
Unmarshalls the XML to the specified domain class. |
4 | fromXml(Class, String, Map)
Unmarshalls the XML to the specified domain class, with additional properties passed through to the JAXBContext used to performed the unmarshalling. |
5 | toXml(Object)
Marshalls the object into XML (using a JAXBContext for the object’s class). |
6 | toXml(Object, Map)
Marshalls the object into XML specifying additional properties (passed to the JAXBContext used for the object’s class). |
7 | toXsd(Object, IsisSchemas)
Generates a map of each of the schemas referenced; the key is the schema namespace, the value is the XML of the schema itself. |
Members
fromXml(JAXBContext, String)
unmarshalls the XML into an instance of the class, using the provided JAXBContext .
fromXml(JAXBContext, String, Map)
unmarshalls the XML into an instance of the class, using the provided JAXBContext and the additional properties.
fromXml(Class, String, Map)
Unmarshalls the XML to the specified domain class, with additional properties passed through to the JAXBContext used to performed the unmarshalling.
toXml(Object, Map)
Marshalls the object into XML specifying additional properties (passed to the JAXBContext used for the object’s class).
toXsd(Object, IsisSchemas)
Generates a map of each of the schemas referenced; the key is the schema namespace, the value is the XML of the schema itself.
A JAXB-annotated domain object will live in its own XSD namespace and may reference multiple other XSD schemas. In particular, many JAXB domain objects will reference the common isis schemas. The IsisSchemas paramter indicates whether these schemas should be included or excluded from the map.
Implementation
Apache Isis provides a default implementation of the service, o.a.i.applib.services.jaxb.JaxbServiceDefault
.
This automatically caches JAXBContext
s for each domain class as requested.
Usage within the framework
This service is provided as a convenience for applications, but is also used internally by the framework to marshall @XmlRootElement-annotated view models.
The functionality to download XML and XSD schemas is also exposed in the UI through mixins of the Dto interface.