You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Introduction

The focus of this Tutorial is to introduce you how you can create, design a simple SOA solution using Camel and OSGI. Most of the current and commercial SOA solutions rely on standards XML/WSDL/BPMN/BPEL and Business Processes (designed through WYSIWYG editor like Eclispe or propriatary product) which are deployed and orchestrated into a Business Process Expression Language engine.

Such a solution can be envisaged for big companies because the skills/time to market are important or when different development standards exist
inside the company like (Java, .NET).

 In the years 90, such developments have been made using CORBA or COM+/DCOM Microsoft technology. But, both of the CORBA and COM approaches had (and still have) significant problems and limitations. Complexity is a big issue. Any of the data that is passed requires very specific formatting, and many of the rules for programming are simply too difficult to follow without encountering errors. Even at the height of their popularity, CORBA was used primarily in large system development staffed by legions of programmers, while COM was used, often reluctantly, by teams of Microsoft developers.

Open Standards Gateway Initiative provides a Java-based platform for integrating both Java and non-Java application components. This technology provides the standardized functions for constructing applications from small, individual components and deploying them as a single application. The core component of OSGi is the OSGi Framework. The OSGi Framework is a very specific class-loading model. In addition to its normal Java execution environment, this framework incorporates an OSGi modules layer that adds private classes for modules and allows for controlled linking between modules. The OSGi Framework also includes life-cycle management for starting, stopping, adding and removing modules, as well as a service registry for sharing objects between modules.

Coupling the OSGI framework with a lightweight Enterprise Service Bus will allow you to design easily the routing between your different modules. A module can be a Plain Old Java Object (POJO), a Web Service designed with Apache CxF framework, a component like an ordering system. In fact, the module or bundle which is the term used by OSGI represent the level of granularity that you identify for your application.

 In this first part of the OSGI tutorial, we will show you how to :

- Create a simple service (derived from the camel-osgi example) module (interface + implementation) and package it as a bundle,

- Create a Camel context with a small routing and package it as a separate bundle,

- The Camel routing will use an OSGI reference to call the simple service

The second part of this tutorial will be derived from the "Reporting Incident Tutorial" and will show you a more real application (which is web based) can be re-scoped into a OSGI application.

Prerequisites

This tutorial uses :

Note: The sample project can be downloaded, see the resources section.

Initial Project Setup

First, we create two eclipse projects using the maven archetype 'spring-osgi-bundle-archetype'. This archetype is helpful because it generates a pom.xml file that we will use with maven goal(s) to create the :

- MANIFEST.MF file (file required and specifying the information about the bundle to deploy on the OSGI server, dependency with another bundle, version, ... )

- jar of the bundle to deploy on the server

To create the simple service project, execute the following command in your Unix/Dos console.

mvn archetype:create -DarchetypeGroupId=org.springframework.osgi -DarchetypeArtifactId=spring-osgi-bundle-archetype -DarchetypeVersion=1.2.0-m2 -DgroupId=demo -DartifactId=demo.service-bundle -Dversion=0.1

Remarks :

- The archetype version depends on the version of Spring Dynamic Module used and must be adapted in consequence,

- According to your project, you can change the artifactId to point to com.mycompany.application.service, and groupId com.mycompany.application

 To create the Camel project, execute the following command

mvn archetype:create -DarchetypeGroupId=org.springframework.osgi -DarchetypeArtifactId=spring-osgi-bundle-archetype -DarchetypeVersion=1.2.0-m2 -DgroupId=demo -DartifactId=demo.camel-bundle -Dversion=0.1

Two folders are created with the following name :

- demo.service-bundle

- demo.camel-bundle

Next, you import these projects into your favorite workspace of Eclipse.

#Resources

  • No labels