Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Scout/HowTo/3.8/Create a Standalone Client with DB Access
The Scout documentation has been moved to https://eclipsescout.github.io/.
A common Scout application typically consists of a client part (front end) and a server part (back end). The client part takes care of presenting the data whereas the server part is responsible for the processing, loading and storing. This is a very clean and powerful architecture for enterprise application. But what if you don't need a server? What if you only want to have a client which accesses the database? Is Scout able to handle this? Yes it is! The key word is offline support.
Contents
Make your application offline capable
An offline Scout application is basically the same as an online Scout application beside the need of a server (like Tomcat). The business logic is still implemented in the server plugins whereas the presentation logic stays at the client plugins. So basically what you need to do is to start the server plugins together with the client plugins.
Follow these steps to make your application offline capable:
Extend the product
Extend your existing client product (SWT or Swing) with the server plugin and its dependencies. If you only add the server plugin org.eclipse.scout.demo.offline.server
you will notice on startup that some plugins are missing. Either use the button "Add Required Plugins" which adds the missing plugins automatically or use "Validate Plugins" in the "Run configuration" and add the missing plugins manually.
Register the offline dispatcher service
Register the OfflineDispatcherService
in your server plugin which actually represents the server on client side and takes care of transactions.
Configure the offline support
Configure the offline support by setting the following property in the config.ini of your clients:
org.eclipse.scout.rt.server.services.common.offline.OfflineDispatcherService#serverSessionClass=WRITE_HERE_CORRECT_PACKAGE.ServerSession
Enable the offline support
Enable the offline support by adding the following code to beginning of the ClientSession#execLoadSession
:
ClientSession.get().goOffline();
This delegates the proxy service calls which are normally received and dispatched by the ServiceTunnelServlet
to the OfflineDispatcherService
.
Benefits of offline support compared to plain jdbc
- Server functionality like transaction handling is available on client side
- DB access and GUI Logic is well separated out of the box because the application design is the same as with a regular Scout client/server applications
- Existing tutorials for client/server applications can be reused since the development process is the same
- Switching to online mode is possible any time if you want to