Reputation: 3458
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?
Upvotes: 8
Views: 2911
Reputation: 14178
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.
Upvotes: 2