3 Replies Latest reply on Apr 8, 2014 2:14 PM by Christian Sadilek

    Programmatic access to Marshaller

    Jasper Oosterman Newbie

      I am using Jackson for Marshalling. Communication between server and client works fine. Objects get serialized and deserialized automatically in the right way. However I am also making use of a message queue (ActiveMQ) for which I would like to (de)serialize the objects.

       

      Is there any way of reusing the Marshaller both 1) on the server and 2) on the client (independent if I use the Jackson or Errai marshaller)?

       

      Kind regards,

      Jasper


      <errai.version>3.0.0.20140214-M4</errai.version>

      <gwt.version>2.5.1</gwt.version>

        • 1. Re: Programmatic access to Marshaller
          Christian Sadilek Master

          Hi Jasper,

           

          On the client, that's possible using MarshallingWrapper.(to|from)JSON(). It will check if Jackson marshalling was enabled (http://docs.jboss.org/errai/3.0-SNAPSHOT/errai/reference/html_single/#sid-19398997_ErraiJAX-RS-Configuration) and is capable of producing and consuming Jackson. On the server, you can use ServerMarshalling(to|from)JSON(). However, on the server, we don't have a utility that consumes and produces Jackson since you can reuse any existing library there.

           

          So, we don't exactly have what you want. If you have a suggestion for an addition or want to send a pull request please let us know.

           

          Cheers,

          Christian

          1 of 1 people found this helpful
          • 2. Re: Re: Programmatic access to Marshaller
            Jasper Oosterman Newbie

            Hi Christian,

             

            Thanks for your answer and sorry for not replying sooner. I got something working with Gson that worked for me but I would still like to do it the correct way so I'll try to rephrase my question:

             

            On the server I can choose to include the errai-jaxrs-provider-${errai.version}.jar which caused the Jackson marshaller to be used and, when missing, uses the ERRAI marshaller instead. This means that somewhere in the ERRAI code the choice between the two marshallers is made and I am wondering how that is done.

             

            Because either way there is a marshaller present that takes care of (de-)serialization so I should not be needing a third party lib such as Gson to do that for me. I hope I have made myself more clear.

             

            Greetings, Jasper

            • 3. Re: Programmatic access to Marshaller
              Christian Sadilek Master

              Hi Jasper,

               

              The errai-jaxrs-provider registers Errai marshalling support (support for Errai's JSON format) with JAX-RS (RestEasy) on the server. If you have RestEasy configured to use Jackson, you don't need to deploy the errai-jaxrs-provider.

               

              The only switch we have is for the client (see link above) to configure which format is expected on the client (Errai's JSON or Jackson).

               

              Cheers,

              Christian