Hi,
I would like to use a (spring) configured XmlAdapter for marshalling and
unmarshalling by CXF.
JAXB exposes a setAdapter() method for this on the Marshaller(
http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/Marshaller.html#setAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)
) and Unmarshaller (
http://docs.oracle.com/javase/7/docs/api/javax/xml/bind/Unmarshaller.html#setAdapter(javax.xml.bind.annotation.adapters.XmlAdapter)
).
Unfortunately I cannot find a way to inject a configured XmlAdapter in the
JAXBDataBinding. What am I missing?
I have resolved the issue for now by patching the DataWriterImpl:
public class DataWriterImpl<T> extends JAXBDataBase implements DataWriter<T> {
...
@SuppressWarnings("rawtypes")
private final XmlAdapter[] adapters;
...
public DataWriterImpl(JAXBDataBinding binding,
@SuppressWarnings("rawtypes") XmlAdapter[] adapters) {
...
this.adapters = adapters;
}
...
public Marshaller createMarshaller(Object elValue, MessagePartInfo part) {
...
for (@SuppressWarnings("rawtypes") XmlAdapter adapter : adapters)
{
marshaller.setAdapter(adapter);
}
return marshaller;
}
And the DataReader<Impl> and JAXBDataBinding in a similar manner.
Is there a better way to do this? Should this be a new feature request?
Regards, -Maarten Winkels