Stepan Vavra
Stepan Vavra

Reputation: 4044

Global Java Type Adapters in MOXy

Is it possible to define global java type adapters/converters in MOXy (up to the newest release (2.6.0)?
Such adapter would be applied by default to all classes registered in jaxb context if not explicitly overridden.

For instance, I would like to add support for all Joda Time types which would require neither a @XmlJavaTypeAdapter at a field nor a class nor a package level.

Upvotes: 5

Views: 275

Answers (2)

marcelv3612
marcelv3612

Reputation: 663

Filed a bug for this.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=478404

Workaround I currently use: Create OXM bindings configuration dynamically at runtime and save it in memory as a String. Then feed it to MOXy via "eclipselink.oxm.metadata-source" property, using StringReaders.

Upvotes: 3

yaroska
yaroska

Reputation: 385

As workaround it's possible to wrap all needed instances with some custom type:

public class MyJodaTime {
  @XmlValue    
  @XmlJavaTypeAdapter(JodaTimeAdapter.class)    
  public DateTime value;
}

Upvotes: 3

Related Questions