if (object instanceof JAXBElement) {
// use the JAXBElement's properties to populate an XMLRoot
element = (JAXBElement) object;
value = element.getValue();
}
RootLevelXmlAdapter adapter = jaxbContext.getTypeMappingInfoToJavaTypeAdapters().get(type);
if (adapter != null) {
try {
value = adapter.getXmlAdapter().marshal(value);
} catch (Exception ex) {
throw new JAXBException(XMLMarshalException.marshalException(ex));
}
}
value = wrapObject(value, element, type);