Archive

Archive for the ‘OSGi’ 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…

Publicités

My first steps with Eclipse RAP [step2]

mai 16, 2011 4 commentaires

In [step1] we have generated our first RAP Hello World Application. RAP Application is (like RCP Application) an Eclipse Plugin which is an OSGi bundle. Before explaining generated code of the RAP Hello World Application you need to understand OSGi.

I’ve decided to explain quickly OSGi by using PDE (Plug-in Development Environment) with 3 articles :

  • [step2] (this article) explains how to create OSGi bundle with PDE, how to run the OSGi container (Equinox) which manage a set of bundles (coming from Workspace + Target Platform) to start/stop bundle with OSGi console.
  • [step3] explains how to OSGi manage the dependencies between several bundles with Required-Bundle and Import-Package declared in the MANIFEST.MF and show in action the OSGi registry services which is used to share services between bundles (SOA Architecture).
  • [step4] explains how to use Servlet into OSGi context with OSGi HttpService. This article is interesting because it will explain how RAP Application works : RAP Servlet org.eclipse.rap.ui.internal.servlet.RequestHandler is called when URL http://127.0.0.1:8080/rap/ is accessed.

In this article we create an OSGi bundle org.akrogen.dynaresume.osgiapplication which defines a simple OSGi Activator which displays in the System.out when the bundle is started and stopped. Here is a scheme which shows in action org.akrogen.dynaresume.osgiapplication managed with OSGi container (Equinox) :

Lire la suite…

Catégories :Eclipse RAP, Equinox

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