I'm currently building a P2P-system which uses Protocol Buffers for all communication between the peers. There's also a some centralized parts of the system where the peers communicate with a server. The server uses JPA to store the data it has about the peers.
So essentially the clients has its data in Protocol Buffers-messages and the server in JPA-entities. My question is therefore if there's a way to automatically convert between them?
What I'm looking for is:
Ideally you could take it one step further and have them both be the same classes (i.e. Protocol Buffers with JPA annotations) but if that's not attainable the above would work as well.
Has this been done and if not do you think it's feasible to implement in a reasonable amount of time?
Yes, you can absolutely combine Protobuf and REST.
Protobuf, the binary format crafted by Google, surpasses JSON performance even on JavaScript environments like Node. js/V8 and web browsers.
Protocol buffers are a combination of the definition language (created in . proto files), the code that the proto compiler generates to interface with data, language-specific runtime libraries, and the serialization format for data that is written to a file (or sent across a network connection).
Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data.
The Java Protocol Buffers API wants to generate the classes. So it seems like it would be hard to then annotate those. Instead, you could start with your own XML "schema", and then have XSLT stylesheets that:
You could then use the google generated files with JPA.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With