tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Tuscany: OSGi Aware Programming in Tuscany (page edited)
Date Wed, 12 Nov 2008 02:11:03 GMT
OSGi Aware Programming in Tuscany (TUSCANY) edited by Luciano Resende
      Page: http://cwiki.apache.org/confluence/display/TUSCANY/OSGi+Aware+Programming+in+Tuscany
   Changes: http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=101617&originalVersion=3&revisedVersion=4


h2.Motivation for OSGi

   The Apache Tuscany project has become a large project, with various extensions and component
types that brings to the SCA Runtime different levels of dependencies. With its growth, Tuscany
also started to have it's SPIs violated by some of these extensions, and some of the boundaries
between sub-systems are broken, as there wasn't any enforcement of these boundaries.

   The OSGi model provides a very powerful and flexible framework to develop applications
in a modular fashion with a high degree of control over classloading inter-dependencies over
modules. An OSGi module (a.k.a bundle) have a manifest file (META-INF\manifest.mf) that contains
module information such as "name", "version" and also a list of what packages are being exported,
and what packages are being imported from the given bundle, providing ways to easily enforce
module boundaries.

   In summary:
* Better class loading mechanism for our modules
* Create clean boundaries between sub-systems

h2.Tuscany and OSGi - 3rd party dependencies

   Currently we are wrapping the 3rd party dependencies as OSGi bundles, but leaving it unpacked
(a.k.a folder structure). This allow use to use the same dependency jars in a OSGi environment
as well as in a non-OSGI environment and generating no side effect on our distribution footprint.

h2.Tuscany and OSGi - Granularity

   The granularity used to define modules should be very familiar to all tuscany developers,

   Tuscany Modules      --> OSGi Bundles
   3rd Party Libraries  --> OSGi Bundles (using unpacked wrap style bundle)

h2.Properly defining new Tuscany modules as an OSGi bundle

 When adding new modules to the Tuscany project, the developer will need to create the OSGi
Manifest to properly describe the new module as an OSGi bundle. These artifacts can be automatically
generated using the Felix maven-bundle-plugin and should be available from svn repository
once it's stable.

h4.Generating OSGi manifest with Felix maven-bundle-plugin

{code:title="configuring maven to generate the OSGi manifest"}
            <!-- Bundle versioned from Tuscany version -->
            <!-- Bundle Symbolic name -->
            <!-- Bundle description from pom description -->
            <!-- Export org.osoa.sca and all sub-packages -->
            <!-- No Import-Package so calculate imports from code dependencies -->

Below is a manifest that was generated for one of the Tuscany modules using the felix maven-bundle-plugin.

{code:title="OSGi Manifest (META-INF\manifest.mf"}
Manifest-Version: 1.0
Export-Package: org.apache.tuscany.sca.assembly;uses:="javax.xml.xpath
Private-Package: org.apache.tuscany.sca.assembly.builder.impl;version=
Tool: Bnd-0.0.255
Bundle-Name: Apache Tuscany SCA Assembly Model
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
Bundle-Vendor: The Apache Software Foundation
Bundle-Version: 1.4
Bnd-LastModified: 1225397097203
Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Assembly Model
Import-Package: javax.xml.namespace,javax.xml.parsers,javax.xml.transf
Bundle-SymbolicName: org.apache.tuscany.sca.assembly
Bundle-DocURL: http://www.apache.org/

h2.Tweaking the OSGi manifest

   Eclipse PDE provides good tooling for editing and maintaining OSGi manifest files. There
are various scenarios we might need to tweak the OSGi manifest manualy :

* Updating imported/exported packages
* Marking test dependencies optional 
** Avoid issues when tests have references to external packages 


This message is automatically generated by Confluence

Unsubscribe or edit your notifications preferences

If you think it was sent incorrectly contact one of the administrators

If you want more information on Confluence, or have a bug to report see

View raw message