I have a Java web application that has a โdisabledโ desktop Java Swing application. Using desktop application users connects to the Internet and downloads the data they need from the server. They can disconnect and use the application offline. When they reconnect to the Internet, they can synchronize their data with the server.
The server itself is a Java EE web application, and the desktop application is a limited functional version of the web application. Until now, all business logic and data access codes have been encoded separately for each application. The data stores were different for each application (SQL Server web server and Desktop are serialized objects). Some new requirements require a lot of development for both applications. Since the functionality is the same, I want to add data access code and business logic so that I can easily use it for both applications.
My plan is as follows.
1) Create a DAO library (JPA)
Switch my DAOs (currently JDBC) to use the Java Persistence API. That way, I can start using RDBMS in a desktop application like derby, sql express or something like that, and reuse entites and DAO code to do all the db operations. I can link this to the class library and use the same library for the web and desktop.
2) Create a library for business logic
The web application is written in struts 2. I will take all the logic in my Action classes, but in POJO. Create a jar class library with business logic. I can add lib to my web project and desktop. Then I can call POJOs from my rack activities and from my desktop application.
I assume that the JPA will take care of duplicating the data access code and put the business logic (which is mostly dao calls) in a separate library to take care of the duplication of business logic.
So my question is: what is a good layer separation strategy for an application that can be used online and offline?
If you have any recommendations for achieving this in a different way, any warning for me when I start this project or any framework that can help me, let me know.
java web-applications swing jpa code-reuse
Allan Aug 11 2018-10-18T00: 00Z
source share