public static Object unmarshalWithBridge(QName qname,
Class<?> cls,
Annotation[] anns,
Set<Class<?>> ctxClasses,
Object source,
AttachmentUnmarshaller am) {
try {
JAXBUtils.BridgeWrapper bridge = JAXBUtils.createBridge(ctxClasses, qname, cls, anns);
if (source instanceof XMLStreamReader) {
return bridge.unmarshal((XMLStreamReader)source, am);
} else if (source instanceof InputStream) {
return bridge.unmarshal((InputStream)source);
} else if (source instanceof Node) {
return bridge.unmarshal((Node)source, am);
} else {
throw new Fault(new Message("UNKNOWN_SOURCE", LOG, source.getClass().getName()));
}
} catch (Exception ex) {
if (ex instanceof javax.xml.bind.MarshalException) {
javax.xml.bind.MarshalException marshalEx = (javax.xml.bind.MarshalException)ex;
Message faultMessage = new Message("MARSHAL_ERROR", LOG, marshalEx.getLinkedException()
.getMessage());
throw new Fault(faultMessage, ex);
}
throw new Fault(new Message("MARSHAL_ERROR", LOG, ex.getMessage()), ex);
}
}