Home Cross-framework Solutions for field Annotations
Reply: 1

Cross-framework Solutions for field Annotations

KG6ZVP
1#
KG6ZVP Published in 2017-12-06 22:29:54Z

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.)

Damodar Periwal
2#
Damodar Periwal Reply to 2017-12-07 20:27:59Z

Disclaimer: I am the architect of JDX for Java and JDXA for Android ORMs.

You may consider using JDX for Java and JDXA for Android ORM frameworks to share the common object model, the core business logic code, and the data integration code across Java server, Java desktop, and Android platforms.

JDX and JDXA don't use annotations to define the mapping - instead they use an external text file to define the mapping specification based on a simple ORM grammar. So you may use the same mapping specification for your common object model across different platforms. Also, the APIs for both JDX and JDXA are simliar.

So, you just need to use the appropriate JDX(A) ORM library for your target platform and an appropriate JDBC driver for your target database without needing to change your object model or business logic.

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO