> I'd like to use dynamically generate/use protocol buffer objects in a
> running Java application.  This would be running in a production
> environment (jre, not jdk) where protoc is not available.
>
> Has anyone written a utility in Java to parse a protocol buffer
> definition and dynamically build Java classes at runtime using
> something like asm?

No need for asm or anything like that, the protobuffer libraries
already contain enough to do what you want to do.

To create a new message definition, you can use DescriptorProto to
create the message, put it in a FileDescriptorProto, and use
FileDescriptor.buildFrom() to build it.  Now you can get the
descriptors out with FileDescriptor.getMessageTypes().

Once you have a message's Descriptor, you can parse messages using
DynamicMessage.parseFrom(), and you can create new messages using
DynamicMessage.Builder.

- Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to