// This is used in RPC
@Override
public T unmarshal(XMLStreamReader in, AttachmentUnmarshaller au)
throws JAXBException {
JAXBUnmarshaller unmarshaller = null;
try {
QName tagName = null;
if (in.getEventType() == XMLStreamConstants.START_ELEMENT) {
tagName = in.getName();
}
unmarshaller = parent.upool.allocate();
unmarshaller.setAttachmentUnmarshaller(au);
Object o;
if (in instanceof XMLStreamReaderEx) {
CustomXMLStreamReaderReader cr = new CustomXMLStreamReaderReader();
XMLStreamReaderInputSource is = new XMLStreamReaderInputSource(
in);
SAXSource saxSource = new SAXSource(cr, is);
o = ((mappingInfo != null) ? unmarshaller.unmarshal(saxSource,
mappingInfo) : unmarshaller.unmarshal(saxSource));
} else {
o = ((mappingInfo != null) ? unmarshaller.unmarshal(in,
mappingInfo) : unmarshaller.unmarshal(in));
}
if (o instanceof JAXBElement) {
o = ((JAXBElement) o).getValue();
}
// TODO recycle to pool
// Workaround for Eclipselink JAXB not consuming END_ELEMENT.
try {
if (in.getEventType() == XMLStreamConstants.END_ELEMENT && in.getName().equals(tagName)) {
in.next();
}
} catch (XMLStreamException e) {
throw new WebServiceException(e);
}
return (T) o;
} finally {
if (unmarshaller != null) {
unmarshaller.setAttachmentUnmarshaller(null);
parent.upool.replace(unmarshaller);
}
}
}