cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maarten Winkels <mwink...@wcc-group.com>
Subject Configuring Xml Adapters for CXF
Date Wed, 29 Oct 2014 14:32:15 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message