Archive

Archive for the ‘Equinox ServletBridge’ Category

Eclipse RCP/RAP and Remoting with JAX-RS, Spring Data JPA and CXF DOSGi [step4]

juin 18, 2012 8 commentaires

In [step3] we have managed our UserService on Client and Server side with JAX-RS and Apache CXF DOSGi.

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.

Lire la suite…

OSGi Equinox in a Servlet Container [step6]

septembre 10, 2010 8 commentaires

In [step5], I have modified bridge WEB Application to use it as Electronic Document Management WEB Application.

A servlet CollectionsServlet defined in bridge WEB Application, display list of ICollection by using CollectionsRegistry singleton.

This singleton is used too in OSGi context by sample.collection1 bundle which register/unregister an instance of ICollection. CollectionsRegistry singleton comes from sample.collections.api JAR stored in /WEB-INF/lib (Tomcat System) and sample.collection1 use CollectionsRegistry (import package sample.collections.api ) singleton too.

In this article I will explain how CollectionsRegistry singleton can be shared between WEB Application context (CollectionsServlet) and OSGi context (sample.collection1 bundle) :

Lire la suite…

Catégories:Equinox ServletBridge

OSGi Equinox in a Servlet Container [step5]

septembre 9, 2010 2 commentaires

In [step4], I have explained how host resources in the bridge WEB Application, and how use custom OSGi bundles (sample.http, sample.http2) directly from the workspace (no need to create and deploy JAR in the /plugins folder) with patch 323707.

In this article [step5] and next article [step6], I will explain how we can enjoy OSGi benefits for an another feature (different from HTTP services to register/unregister servlet) in OSGi Equinox in a Servlet Container. The bridge WEB Application can become Electronic Document Management WEB application which is composed with list of Documentary Collection. Each Documentary Collection is an OSGi bundle that we can start/stop with OSGi console to register/unregister it from the list of Documentary Collection. Here a scheme which explains this idea :

This scheme show you 3 sides :

Lire la suite…

Catégories:Equinox ServletBridge

OSGi Equinox in a Servlet Container [step4]

septembre 8, 2010 13 commentaires

In [step3], I have explained why it’s important to define Target Platform with OSGi Equinox in a Servlet Container to compile your custom bundle (sample.http, sample.http2…) with the bundles JARs coming from bridge/WebContent/WEB-INF/eclipse/plugins folder (and not coming from the Eclipse IDE).

In [step2], we have seen 2 problems :

  • It’s impossible to host some resources (HTML, Javascript, Servlet…) in the bridge WEB Application (when /* URL pattern is used). I will explain how fix this problem by using BridgeFilter coming from patch 323707.
  • It’s impossible to use directly the OSGi bundle coming from the workspace. You must create a JAR and copy/paste to the /plugins folder. I will explain how fix this problem by using ${workspace_loc} wildcard (to declare bundles in config.ini) coming from patch 323707.

The current distribution of OSGi Equinox in a Servlet Container doesn’t manage this 2 features, so I have decided to improve it with patch 323707. In this article I will explain how use this patch to manage the 2 problems explained below.

Lire la suite…

Catégories:Equinox ServletBridge

OSGi Equinox in a Servlet Container [step3]

septembre 6, 2010 6 commentaires

In [step2], we have explained how bridge and sample.http works. We have seen several problems (4 problems) with OSGi Equinox in a Servlet Container. In this article we will fix 2 problems :

  • It may that /sp_redeploy doesn’t work with WTP Web Dynamic Project. I had the problem once, so I will explain more the problem, how fix it and we will understand how WTP deploy the WEB application.
  • when bundle (ex : sample.http2) is developed in the workspace, it use JAR coming from the Eclipse IDE and not from the /bridge/ WEB-INF/WebContent/eclipse/plugins folder. We have seen it can cause problem when bundle is deployed ( in the Import Packages Problem [step2] section). I will explain how we can fix this problem with Target Platform.

Lire la suite…

Catégories:Equinox ServletBridge

OSGi Equinox in a Servlet Container [step2]

septembre 2, 2010 10 commentaires

In [step1], I have explained how use Equinox in a Servlet Container with the provided bridge.war and show the sample sample.http in action with WTP Dynamic Web project.

In this article, I will explain :

  • how bridge WEB application works : explains the content of the web.xml which declare the servlet BridgeServlet which is used to startup/shutdown the OSGi container and retrieve the well Servlet from the OSGi services registry according to the request URI path (ex : /hellowrd).
  • how sample.http works. To explains that, we will create from scratch with PDE Tools a new bundle sample.http2 which will provide a new Servlet with path /helloworld2.
  • how add OSGi Web console by using OSGi Felix Webconsole.

We will see several problems with OSGi Equinox in a Servlet Container that we will fix in the next article [step3].

Lire la suite…

Catégories:Equinox ServletBridge

OSGi Equinox in a Servlet Container [step1]

septembre 1, 2010 11 commentaires

In [step0], I have introduced the capability to use OSGi bundles in WEB Application with Server-Side Equinox which works with 2 means :

Those articles will speak about Equinox in a Servlet Container which provides a bridge.war WEB application to start using Equinox in a Servlet Container and a basic OSGi bundle sample.http, example which provides as an OSGi service an HTTP Servlet.

This sample show you it’s possible to available/disable a servlet WITHOUT stopping the HTTP server. In this article I will explain step by step how use bridge.war and show in action the using of sample.http. Steps of this article will be :

  • create an empty bridge WEB Application with WTP Dynamic Web Project to launch the WEB application with Run As->Run on server. Tomcat 6.0 server will be used in this article.
  • copy the content of the bridge.war to the empty bridge WEB Application (WTP Dynamic Web Project) and launch it.
  • install and use the OSGi bundle sample.http.

This article introduce just the features of the bridge.war but will not explain the bridge architecture and will not explain the code of the sample.http. I will do that in the next article [step2].

Lire la suite…

Catégories:Equinox ServletBridge
Suivre

Recevez les nouvelles publications par mail.

Rejoignez 169 autres abonnés