Developing and deploying Web services as an OSGi package

Source: Internet
Author: User
Tags pack versions web services tomcat apache tomcat

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.