Yea bit of a false positive I'm afraid. I ended up getting it to be used in
a manual mapping operation and saw it was being called but unfortunately
its not being used when called via jax-rs

Will battle on a bit more before reverting to annotations

On 14 October 2017 at 10:27, Romain Manni-Bucau <[email protected]>
wrote:

> Hmm, earlier in the boot process shouldn't change anything if you
> manage yourself the builder, can you add why it impacted the behavior
> please (for completeness of this thread)?
>
> side note: you can add annotations on generated jaxb models ->
> https://github.com/highsource/jaxb2-annotate-plugin .
>
> Romain Manni-Bucau
> @rmannibucau |  Blog | Old Blog | Github | LinkedIn
>
>
> 2017-10-14 10:08 GMT+02:00 Paul Carter-Brown <paul.carter-brown@smilecoms.
> com>:
> > Hi Romain,
> >
> > I managed to get it to work by calling new MapperBuilder().addAdapter(new
> > JavascriptDate()).build(); far earlier in the bootup process.
> >
> > On 14 October 2017 at 09:40, Paul Carter-Brown <
> > [email protected]> wrote:
> >
> >> Hi Romain,
> >>
> >> The model is generated using jaxb from an XSD. Jaxb has been set up to
> map
> >> xs:dateTime to java.time.Instant
> >>
> >> getters/setters look like this:
> >>     public Instant getDate() {
> >>         return date;
> >>     }
> >>
> >>     public void setDate(Instant value) {
> >>         this.date = value;
> >>     }
> >>
> >> As the model is generated I don't have the option of adding annotations
> on
> >> it and need to configure Johnzon to globally deal with Instant data type
> >>
> >> Paul
> >>
> >> On 14 October 2017 at 09:36, Romain Manni-Bucau <[email protected]>
> >> wrote:
> >>
> >>> Hi
> >>>
> >>> What is your model?
> >>>
> >>> Did you try @JohnzonConverter too?
> >>>
> >>> Tomee uses an old johnzon too so can need some enhancements from
> master.
> >>>
> >>> Le 14 oct. 2017 03:10, "Paul Carter-Brown"
> <[email protected]
> >>> om>
> >>> a écrit :
> >>>
> >>> > Hi,
> >>> >
> >>> > I've created an adapter as follows:
> >>> >
> >>> > public class JavascriptDate implements Adapter<String, Instant> {
> >>> >
> >>> >     @Override
> >>> >     public String to(Instant instance) {
> >>> >         final Calendar cal = GregorianCalendar.getInstance();
> >>> >         cal.setTime(Date.from(instance));
> >>> >         return DatatypeConverter.printDateTime(cal);
> >>> >     }
> >>> >
> >>> >     @Override
> >>> >     public Instant from(String text) {
> >>> >         return DatatypeConverter.parseDateTime(text).getTime().
> >>> > toInstant();
> >>> >     }
> >>> > }
> >>> >
> >>> > and register it globally like this in a servlet init:
> >>> >
> >>> > new MapperBuilder().addAdapter(new JavascriptDate()).build();
> >>> >
> >>> > When I call a rest service passing a date formatted string field that
> >>> needs
> >>> > to map to an Instant I get an error:
> >>> >
> >>> > org.apache.johnzon.mapper.MapperException: Using fallback converter,
> >>> this
> >>> > only works in write mode but not in read. Please register a custom
> >>> > converter to do so.
> >>> > at
> >>> > org.apache.johnzon.mapper.MappingParserImpl$FallbackConverte
> >>> r.fromString(
> >>> > MappingParserImpl.java:715)
> >>> > at org.apache.johnzon.mapper.internal.ConverterAdapter.to
> >>> > (ConverterAdapter.java:37)
> >>> > at org.apache.johnzon.mapper.internal.ConverterAdapter.to
> >>> > (ConverterAdapter.java:24)
> >>> > at
> >>> > org.apache.johnzon.mapper.MappingParserImpl.convertTo(
> >>> > MappingParserImpl.java:682)
> >>> > at
> >>> > org.apache.johnzon.mapper.MappingParserImpl.toObject(
> >>> > MappingParserImpl.java:523)
> >>> > at
> >>> > org.apache.johnzon.mapper.MappingParserImpl.toValue(
> >>> > MappingParserImpl.java:634)
> >>> > at
> >>> > org.apache.johnzon.mapper.MappingParserImpl.buildObject(
> >>> > MappingParserImpl.java:318)
> >>> > at
> >>> > org.apache.johnzon.mapper.MappingParserImpl.readObject(
> >>> > MappingParserImpl.java:133)
> >>> >
> >>> >
> >>> > Any ideas why my mapper is not being used?
> >>> >
> >>> > Thanks
> >>> > Paul
> >>> >
> >>> > --
> >>> >
> >>> >
> >>> > This email is subject to the disclaimer of Smile Communications at
> >>> > http://www.smilecoms.com/home/email-disclaimer/ <
> >>> http://www.smilecoms.com/
> >>> > disclaimer>
> >>> >
> >>> >
> >>>
> >>
> >>
> >>
> >>
> >>
> >
> >
> > --
> >
> > *Paul Carter-Brown*
> >
> > *Group Chief Information Officer*
> >
> > *Smile Communications Pty (Ltd)       *
> > Smile +234 (0) 702 000 1234
> > Mobile +27 (0) 83 4427 179
> > Skype PaulC-B
> > [email protected]
> > www.smilecoms.com
> >
> > --
> >
> >
> > This email is subject to the disclaimer of Smile Communications at
> http://www.smilecoms.com/home/email-disclaimer/ <http://www.smilecoms.com/
> disclaimer>
> >
>



-- 

*Paul Carter-Brown*

*Group Chief Information Officer*

*Smile Communications Pty (Ltd)       *
Smile +234 (0) 702 000 1234
Mobile +27 (0) 83 4427 179
Skype PaulC-B
[email protected]
www.smilecoms.com

-- 


This email is subject to the disclaimer of Smile Communications at 
http://www.smilecoms.com/home/email-disclaimer/ 
<http://www.smilecoms.com/disclaimer>

Reply via email to