3 Replies Latest reply on Apr 13, 2011 11:14 AM by dward

    Using Transformers for serialization

    kcbabo

      David and I were chatting about using transformers with serialization yesterday and I thought it would be good to take the discussion to the forums for wider input.  In my mind, there are two potential use cases here:

       

      1) We have a requirement that all message content must be a JavaBean, or at least be able to be converted to a JavaBean representation.  So one use of transformers would be to convert a non-conformant object to a JavaBean representation.  This would be a transformer that the user could package with their application.  We need to decide on what the appropriate "to" type would be in this scenario -- java.beans.BeanInfo?

       

      2) As part of serializing exchanges, we need to transform the exchange to a serializable form.  The advantage of putting this in a transform is that different transformer implementations can be swapped out to change the serialization strategy (JSON, byte[], XML, etc.).

       

      Does the above make sense?

        • 1. Using Transformers for serialization
          kcbabo

          Just to clarify on use case #1 above, the requirement for a JavaBean is for user-supplied classes.  For example, if your content type is XML, you will not need to convert to a JavaBean.  The requirement for a JavaBean representation is there to avoid class incompatibility issues that come up using Java serialization.

          • 2. Using Transformers for serialization
            dward

            Instead of using Transformers for Serialization, we can think in the other direction: Serializers for Transformation.

             

            We have 2 JIRAs out there now where we want to implement a new kind of Transformer: JSON and Protobuf

             

            Implementing these by wrapping existing Serializers is brain-dead easy.  Please see my comments on each JIRA here:

            https://issues.jboss.org/browse/SWITCHYARD-183

            https://issues.jboss.org/browse/SWITCHYARD-190

            • 3. Using Transformers for serialization
              dward

              OR! We could just have a single Transformer that uses SerializerType to key off of:

               

              <transform.serial type="JSON_PROTOSTUFF"/> or <transform.serial type="PROTOBUF_PROTOSTUFF"/>

               

              The value of the type attribute would be the SerializerType enum name, per: http://goo.gl/uqsDM

               

              This way we don't have to have separate Transformers for every type of serialization we want to do.