Objectify - Add @Id to any class
I have many custom object classes used by both a server (GAE) and client (Android) in a RESTful system. For ease of maintainability, the code 开发者_JS百科for these objects is common between server and client.
In order to make these objects storable with Objectify on the server side, one field must be annotated @Id. However, I can't do this in each object class without importing javax.persistence on the client (or creating separate client/server copies of the code) (or, for every object, creating a "StorableX extends X" with cloning).
Is it possible to use an adapter or wrapper pattern to dynamically make any object storable via Objectify? What is the best practice for this?
Thanks, --John
There is normally no problem using an annotated class without the annotation interface being present in the classpath, even if the annotation is a runtime one. Of course, if the class byte-code is instrumented or if some class tries using the annotation at runtime, it's another matter.
精彩评论