I have a Java web application that has a 'disconnected' Java Swing desktop app. Using the desktop app users connect to the internet and download data they need from a server. They can disconnect and use the application offline. When they reconnect to the internet they can sync their data back to the server.
The server itself is a Java EE web application and the desktop app is a limited functionality version of the web app. Up until now all business logic and data access code was coded separately for each application. The data stores were different for each application (Web is SQL Server and Desktop is Serialized objects). Some new requirements involve a lot of development to both applications. Since the functionality is the same I want to layer the data access code and business logic so I can easily reuse it for both applications.
My plan is to do the following.
1) Create a DAO library (JPA)
Switch my DAOs (currently JDBC) to use Java Persistence API. This way I can start using a RDBMS on the desktop app like derby, sql express or something similar and reuse the entites and DAO code to do all of the db operations. I can bundle this into a class library and use the same library for the web and the desktop.
2) Create a library for business logic
The web app is written in struts 2. I will take all of the logic in my Action classes and but it in POJOs. Create a jar class library with the business logic. I can add the lib to my web and desktop project. Then I can call the POJOs from my struts actions and from my desktop application.
I assume that the JPA will take care of duplicating the data access code and putting the business logic (which for the most part are dao calls) in a separate library will take care of duplicating the business logic.
So my question is: What is a good strategy for seprating layers for an appication that can be used online and offline?
If you have any recommendations for achieving this differently, any warning for me as I begin this project or any frameworks that might help me please let me know.
Thank you.