Home Cross-framework Solutions for field Annotations
Reply: 0

Cross-framework Solutions for field Annotations

user1546 Published in April 22, 2018, 12:35 am

Does anyone have any strategies or examples of cross-framework libraries?

I am working on a project with an android app, a java server and a Java desktop client, which all use different frameworks. I need to refactor some core business logic into a separate library that can be used across all of these to ensure consistent behavior, but the field annotations are killing me.

The problem is that I am using Room in the Android app (which requires the @PrimaryKey annotation on the primary key field of a database entity) and JPA in the server and JavaFX client (which requires @Id).

Given this level of difficulty with the models, we initially copy-pasted the fields without annotations to the others when changing them. However, the business logic needs to make use of the models and accommodate each platform's specific ORM, Http client and Json serializer. (I know that it is technically possible to get Gson, Apache Http and Hibernate to run on all of these platforms, but actually doing any of these solutions created too many nightmares of its own)

As far as I can tell, there isn't a nice solution to this. Fortunately, the same @Inject is used in Dagger2 and CDI/CDI-SE so I have created some interfaces that each platform/framework will implement.

Does anybody have any examples or case studies I could look at which might help me arrive at a solution?

(I realize this question doesn't include any code samples, but it's more of a general programming strategy question.)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.297864 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO