Details

    • Type: Feature Request
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: transformation
    • Labels:
      None

      Description

      Add a transform.proto to allow transform to/from Google Protocol Buffer messages.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            dward David Ward added a comment -

            FYI, using the Protostuff library (which we already do for Serialization), you can map to/from Google Protobuf using their ProtobufIOUtil class very easily.

            Or (better yet), you can just wrap our existing ProtobufProtostuffSerializer (http://goo.gl/ZJcQf) inside your Transformer. It would look like this:

            import org.switchyard.internal.io.*;
            Serializer ser = SerializerType.PROTOBUF_PROTOSTUFF.instance();

            // using byte arrays
            MyPojo mypojo = new MyPojo();
            byte[] bytes = ser.serialize(mypojo, MyPojo.class);
            mypojo = ser.deserialize(bytes, MyPojo.class);

            // using streams
            MyPojo mypojo = new MyPojo();
            int bytesWritten = ser.serialize(mypojo, MyPojo.class, out); // (out is your OutputStream)
            mypojo = ser.deserialize(in, MyPojo.class); // (in is your InputStream)

            There are plenty of Serializers available. Checkout: http://goo.gl/uqsDM
            You can also customize serialization with your own Strategy. Checkout: http://goo.gl/A5GV8

            Hope this helps!

            Show
            dward David Ward added a comment - FYI, using the Protostuff library (which we already do for Serialization), you can map to/from Google Protobuf using their ProtobufIOUtil class very easily. Or (better yet), you can just wrap our existing ProtobufProtostuffSerializer ( http://goo.gl/ZJcQf ) inside your Transformer. It would look like this: import org.switchyard.internal.io.*; Serializer ser = SerializerType.PROTOBUF_PROTOSTUFF.instance(); // using byte arrays MyPojo mypojo = new MyPojo(); byte[] bytes = ser.serialize(mypojo, MyPojo.class); mypojo = ser.deserialize(bytes, MyPojo.class); // using streams MyPojo mypojo = new MyPojo(); int bytesWritten = ser.serialize(mypojo, MyPojo.class, out); // (out is your OutputStream) mypojo = ser.deserialize(in, MyPojo.class); // (in is your InputStream) There are plenty of Serializers available. Checkout: http://goo.gl/uqsDM You can also customize serialization with your own Strategy. Checkout: http://goo.gl/A5GV8 Hope this helps!
            Hide
            kcbabo Keith Babo added a comment -

            Dropping from a specific version until someone can pick it up.

            Show
            kcbabo Keith Babo added a comment - Dropping from a specific version until someone can pick it up.
            Hide
            cwash Chris Wash added a comment -

            Started on this - added raw transformer classes and unit test so far. https://github.com/cwash/core/compare/SWITCHYARD-190

            Obviously a good deal more plumbing work is needed and much more testing. But here are some points of interest:

            • Dependency introduced on protobuf 2.4.1 - comment in to add this to dependencyManagement in the parent POM at some point in the future.
            • Did not use serializer as comment above suggested, would also bring in dependency between transform and serial that does not currently exist.
            • Currently only using byte[] and not streams. At first glance I didn't understand the implications of passing a stream in the org.switchyard.Message#content so I decided to stick with byte[] for now.
            Show
            cwash Chris Wash added a comment - Started on this - added raw transformer classes and unit test so far. https://github.com/cwash/core/compare/SWITCHYARD-190 Obviously a good deal more plumbing work is needed and much more testing. But here are some points of interest: Dependency introduced on protobuf 2.4.1 - comment in to add this to dependencyManagement in the parent POM at some point in the future. Did not use serializer as comment above suggested, would also bring in dependency between transform and serial that does not currently exist. Currently only using byte[] and not streams. At first glance I didn't understand the implications of passing a stream in the org.switchyard.Message#content so I decided to stick with byte[] for now.
            Hide
            dward David Ward added a comment -

            FYI, protobuf 2.4.1 is already a dependency in the parent pom, as our rules and bpm components depend on it, since drools and jbpm serialize their data using protobuf when storing their state. It's already in our JBoss AS7 modules/com/google/protobuf/main/module.xml too.

            Show
            dward David Ward added a comment - FYI, protobuf 2.4.1 is already a dependency in the parent pom, as our rules and bpm components depend on it, since drools and jbpm serialize their data using protobuf when storing their state. It's already in our JBoss AS7 modules/com/google/protobuf/main/module.xml too.
            Hide
            cwash Chris Wash added a comment -

            Thanks, David - you're right, not sure how I missed that - IntelliJ/Maven complained about it at first... Yanking version out.

            I want to add a few more tests to make sure everything is getting Serialized/Deserialized correctly - but any concerns with the transformer approaches?

            I'll work on getting the Transformers loading from configuration values after that.

            Show
            cwash Chris Wash added a comment - Thanks, David - you're right, not sure how I missed that - IntelliJ/Maven complained about it at first... Yanking version out. I want to add a few more tests to make sure everything is getting Serialized/Deserialized correctly - but any concerns with the transformer approaches? I'll work on getting the Transformers loading from configuration values after that.
            Hide
            dward David Ward added a comment -

            Transformation isn't one of my areas of focus/expertise in SwitchYard, so I'm gonna hafta let others (most likely Keith) look over your approach. Sorry.

            Show
            dward David Ward added a comment - Transformation isn't one of my areas of focus/expertise in SwitchYard, so I'm gonna hafta let others (most likely Keith) look over your approach. Sorry.
            Hide
            kcbabo Keith Babo added a comment -

            Hey Chris - this looks like a promising start! A few comments:

            In Java2ProtobufTransformer:

            • The check for com.google.protobuf.Message is valid provided that all generated classes extend this type. From your proto definition, it appears that they do, but figured I would point it out.
            • You can also use this to get the protobuf.Message from the message content
              com.google.protobuf.Message protobufMessage = message.getContent(com.google.protobuf.Message.class);

            In Protobuf2JavaTransformer:

            • You will want to use something like this instead of the cast to byte[]:
              InputStream protobufBytes = message.getContent(InputStream.class);

            The reason for the above is that our internal converters will automatically convert readers, byte buffers, etc. into a stream.

            Show
            kcbabo Keith Babo added a comment - Hey Chris - this looks like a promising start! A few comments: In Java2ProtobufTransformer: The check for com.google.protobuf.Message is valid provided that all generated classes extend this type. From your proto definition, it appears that they do, but figured I would point it out. You can also use this to get the protobuf.Message from the message content com.google.protobuf.Message protobufMessage = message.getContent(com.google.protobuf.Message.class); In Protobuf2JavaTransformer: You will want to use something like this instead of the cast to byte[]: InputStream protobufBytes = message.getContent(InputStream.class); The reason for the above is that our internal converters will automatically convert readers, byte buffers, etc. into a stream.

              People

              • Assignee:
                Unassigned
                Reporter:
                kcbabo Keith Babo
              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Development