Embedding an HTTP server in Equinox
At this step the server side works with the HTTP Server Jetty which is an OSGi bundles. This mode is called Embedding an HTTP server in OSGi container : it means that HTTP server and WEB application are OSGi bundles. The OSGi container starts the HTTP server bundle. Embedding an HTTP server in Equinox explains how this mean is done with Equinox.
You can resume "embedding an HTTP server in OSGi container" like this :
OSGi container -> HTTP Server (bundle) -> WEB Application (bundle).
Equinox in a Servlet Container (ServletBridge)
It works great but sometimes you have not the luck to have an HTTP Server which supports OSGi like Apache Tomcat. For instance in our case, when we wished to deploy our XDocReport RAP Application on CloudBees, whish provides an Non OSGI HTTP Server Apache Tomcat.
Fortunatly, Server-Side Equinox provides Embedding OSGi container in a servlet container mode : it means that it’s a WEB Application which contains the OSGi container (and another bundles) which start the OSGi container. Equinox in a Servlet Container explains how this mean is done with Equinox.
You can resume "embedding OSGi container in a servlet container" like this :
HTTP Server -> WEB Application -> OSGi container.
To manage this mode you must create a classic WAR which hosts your OSGi plugins and ServletBridge. In this article we will explain how to create a WAR with our UserService on server side with the Eclipse Plug-In Libra WAR Product which was created for creating WAR from RAP Application launches. But it can be used too with OSGi launches (like we need in this article).
To create a WAR of CXF DOSGi application (server side), you must :
- register your JAX-RS service with HttpService :
<!-- HttpService --> <entry key="org.apache.cxf.rs.httpservice.context" value="/UserService" />
- create a WAR which hosts OSGi bundles and ServletBridge. WAR Product gives you the capability to create a *.warproduct file from a launch (RAP, RCP, OSGi lanches, etc). This *.warproduct file is used to export it into a WAR to generate WAR.
At the end of this article we will create the the cxf-dosgi-jpa.war WAR. I have deployed this WAR on the CloudBees to see it on action. You can test for instance go at http://cxf-dosgi-war.opensagres.cloudbees.net/UserService/user/findAll to see JSON of the all users.
In [step7] we have seen how to use Spring Data JPA to add custom methods to the Dao to manage criteria and pagination.
In this article we will implement a Rich Client with RCP Application to display User list in a SWT Table :
In business application with large data, display data in a table with navigation page can be really helpful. In our XDocReport project, we need this feature in our Eclipse RCP/RAP XDocReport application for instance to select resumes to open in the Search Resume Dialog :
This last screenshot is the resume search dialog in WEB context (Eclipse RAP). Here a screenshot in fat client context (Eclipse RCP) :
After several search, it seems that there is no project which provides a SWT pagination control, which works with Eclipse RCP and RAP. So we decided to develop this control and give our code to Eclipse Nebula Project.
Today Nebula Team are voting if the project will be accepted or not. Pagination control was accepted by Nebula and today it is stored on Eclipse Nebula Git.
If you are intersted you can read the original bug 367064.
In some business application, your model (domain) contains sometimes image byte array (ex : photo for person model, logo for project model, etc). In our XDocReport project, we need to manage photo byte array with SWT control for the person model in our Eclipse RCP/RAP XDocReport, in the resume editor :
This last screenshot is the resume editor in WEB context (Eclipse RAP). Here a screenshot in fat client context (Eclipse RCP) :
After several search, it seems that there is no project which provides a SWT picture control, which works with Eclipse RCP and RAP. So we decided to develop SWT PictureControl and give our code to Eclipse Nebula Project.
Today Nebula Team are voting if the project will be accepted or not. Pictur control was accepted by Nebula and today it is stored on Eclipse Nebula Git.
If you are intersted you can read the original bug 365948.
- create an Eclipse RAP with PDE Template "RAP Application with a view" which generates this WEB Application :
- create an Eclipse RCP with PDE Template "RCP Application with a view" which generates this Fat client Application :
At the end of this article we will compare the two generated RAP and RCP Application code to see the differences between RCP and RAP Application. We will use this comparison in the [step8] to manage RAP (WEB Application) and RCP (Fat client) application with the same code (Single Sourcing).
Dans le billet précédant [step12] nous avons initialisé le client RCP qui affiche une liste statique de Users.
Dans ce billet nous allons faire appel au service UserService pour afficher la liste des Users. Un bouton Refresh Users permettra de rappeler le service UserService pour rafraîchir la liste des users :
Pour récupérer le service UserService dans la View, nous utiliserons 2 techniques possibles :
- un ServiceTracker classique OSGi.
- la déclaration XML Spring DM <osgi:reference ou nous montrerons comment passer par injection de dépendance le service UserService à la View.
Nous montrerons aussi comment créer des launch qui permettent de lancer :
- l’application RCP en tant que Client lourd (les services sont dans le même conteneur OSGi que l’application RCP).
- l’application RCP en tant que Client (Serveur) qui fait appel à un serveur pour utiliser les services.