I’m using CXF 2.4 with JAXB.
Could I have a global XmlAdapter for all instances of my owm class (e.g. LWDate)?
I wrote a class:
public class LWDateAdapter extends XmlAdapter<Date, LWDate>
Right now I have to add @XmlJavaTypeAdapter on each param, method or package that I plan to use with CXF. E.g.
@WebMethod void test (@WebParam(name="Birthdate") @XmlJavaTypeAdapter(LWDateAdapter.class) LWDate pBirthdate){}
I wish to ask CXF/JAXB always bind my class LWDate to java.util.Date is it possible?
UPDATE: @XmlJavaTypeAdapter works on a package level staring from version 2.4.4 according to that issue.
For your use case using the
@XmlJavaTypeAdapterannotation at the package level is your best option. Below is a post where I use this strategy for the Joda-Time classes:If you have a domain class that you always want to be handled with an
XmlAdapteryou can use the@XmlJavaTypeAdapterannotation at the type level: