SOA strategy for deploying and supporting multiple versions of WEB services
Brief introduction
OSGi is a Java-oriented dynamic modular system. The OSGi Alliance publishes specifications for the module system. Some of the popular OSGi containers include Eclipse Equinox and Apache Felix, among others. As a framework for developing and deploying modular, reusable Java programs, OSGi presents a strong momentum of development.
The OSGi container allows you to deploy a Java module in Jar format (OSGi calls it "package"). An interesting feature of OSGi is the ability to deploy multiple versions of a service pack into the same container. All packages deployed into the OSGi container run in a single JVM. If the client of a service is outside the OSGi container, then the service pack needs to have distributed functionality. The Apache Cxf-dosgi is a new service framework that supports the distributed functionality for OSGi packages.
When a Web service provider develops a new version of the service, it is often necessary to continue supporting the existing client. Therefore, a WEB service provider needs to deploy and maintain multiple versions of the service at the same time. OSGi naturally becomes an excellent choice to meet this need.
Since the CXF team released a new framework called CXF-DOSGI (which supports the distribution of OSGI packets), I chose Eclipse Equinox as the container for OSGi and chose Apache CXF as the WEB services framework. By using this framework, we can develop and deploy WEB services as OSGi packages. Because multiple versions of a package can coexist, one can deploy and maintain multiple versions of WEB services at the same time. I will use Apache Tomcat as a servlet container for deploying clients.
In this article, I'll describe the detailed methodology for developing CXF-DOSGI service packs and how to deploy them in an OSGi container and access them using a simple WEB client (and the OSGi container running in a different JVM). I will also describe the development of different versions of the same service and deploy it to the same OSGi container, and demonstrate that the two different versions of the service can coexist and serve multiple types of clients.
Prerequisite
First download and install Eclipse 3.5 (Galileo). Eclipse 3.5 contains an OSGi framework called Equinox
Then download the CXF-DOSGI and OSGi compendium packages. Download the two packages and save them to the same directory locally.
Download and install the Apache Tomcat 5.5.9. We will use the servlet container outside of the OSGi container (Eclipse) to install and run our service clients.
Preparing the OSGi container
Before developing a distributed service pack, start the container and register the CXF-DOSGI as the service provider enabler to prepare for the OSGi container.
Use an empty workspace to start Eclipse 3.5. Set the perspective to "Plug-In Development". An Eclipse plug-in is essentially an OSGi package.
Next, use the menu options to import the Cxf-dosgi OSGi Compendium Package and the OSGi Compendium package:
File/import/plug-in Development/plug-ins and Fragments
Then select the directory where the download package resides. See Figure 1 below.
Figure 1. Import the required packages. Specify directory Location