Return-Path: Delivered-To: apmail-tuscany-commits-archive@www.apache.org Received: (qmail 67193 invoked from network); 6 May 2010 08:30:27 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 May 2010 08:30:27 -0000 Received: (qmail 38401 invoked by uid 500); 6 May 2010 08:30:26 -0000 Delivered-To: apmail-tuscany-commits-archive@tuscany.apache.org Received: (qmail 38335 invoked by uid 500); 6 May 2010 08:30:25 -0000 Mailing-List: contact commits-help@tuscany.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tuscany.apache.org Delivered-To: mailing list commits@tuscany.apache.org Received: (qmail 38327 invoked by uid 99); 6 May 2010 08:30:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 08:30:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 May 2010 08:30:21 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o468U0jX010030 for ; Thu, 6 May 2010 08:30:00 GMT Date: Thu, 6 May 2010 04:30:00 -0400 (EDT) From: confluence@apache.org To: commits@tuscany.apache.org Message-ID: <23027106.1815.1273134600015.JavaMail.confluence@thor> Subject: [CONF] Apache Tuscany Docs 2.x > Classloading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Auto-Submitted: auto-generated X-Virus-Checked: Checked by ClamAV on apache.org Space: Apache Tuscany Docs 2.x (http://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x) Page: Classloading (http://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/Classloading) Edited by Simon Laws: --------------------------------------------------------------------- Need to detail the various ways the Tuscany runtime loads classes and the issues involved. Here are some notes to kick of this document h1. Classloading Objectives The runtime must work in both OSGi and non-OSGI environments. I.e. we can't rely on the OSGi service registry for extensibility The runtime must not be genberally environment specific. I.e. no buddy classloading ... h1. General Patterns h2. Extension loading - JSE tuscany-extensibility Tuscany finds extensions by looking for META-INF/services files on the classpath. h2. Extension loading - OSGi tuscany-extensibility-equinox It's a bit more complicated here. The extensibility-equinox bundle is given the entire OSGi context at start up and from there is looks in all of the loaded bundles looking for META-INF/services files. It caches them against the bundle in which they are found. The tuscany-extensibility-equinox bundle also has a dynamic import {code} DynamicImport-Package: org.apache.tuscany.sca.extensibility.equinox, javax.transaction;version="1.1", javax.transaction.xa;version="1.1", {code} Which allows it to generally load any classes in the runtime h2. Split Packages - JSE We don't take any special account of this in JSE (?) We avoid split packages across the JARs we create as it messes OSGi up. h2. Split Packages - OSGI We avoid split packages across the bundles we create They may exist in third party bundles (or jars that we turn into bundles) so we need a way round it The Tuscany eclipse plugin is used to generate bundles manifest for jars which don't have them. This is done automatically with all packages exported (?) and the resulting bundle it in the distribution modules directory in the following form {code} bundle-name META-INF MANIFEST.MF bundle-name.jar {code} The MANIFEST.MF is generated and will have a bundle classpath pointing to the jar (which doesn't itself have a manifest The runtime (node-launcher-equinox) has code to load these directories as bundles. There is a way of overriding these automatically generated bundles so that split packages (or any other manifest problems) can be worked round. Generate the manifest manually and put it in {code} distribution/all/manifests {code} Update distribution/pom.xml to configure the Tuscany version of the maven bundle plugin to apply this manifest {noformat} org.apache.tuscany.maven.plugins maven-bundle-plugin 1.0.6 distribution-modules generate-resources generate-modules target/modules ${useDistributionName} ${generateAggregatedBundle} true org.apache.ws.commons.axiom axiom-api 1.2.8 ${basedir}/manifests/axiom-api-1.2.8.MF org.apache.woden woden-impl-dom 1.0M8 ${basedir}/manifests/woden-impl-dom-1.0M8.MF org.apache.axis2 axis2-kernel 1.5.1 ${basedir}/manifests/axis2-kernel-1.5.1.MF org.apache.axis2 axis2-transport-http 1.5.1 ${basedir}/manifests/axis2-transport-http-1.5.1.MF org.apache.axis2 * * org.eclipse osgi 3.3.0-v20070530 {noformat} You'll note that there is an artifact aggregation element that doesn't work at the moment. This should aggregate the two bundles together so that a split package isn't an issue. As this doesn't work at the moment another way to achieve the same result is to make one package a fragement of the other by configuring separate manifests manually. NOTE!!!!! you also need to put the manually generated manifest in node-launcher-equinox\src\main\resources\org\apache\tuscany\sca\node\equinox\launcher otherwise you'll spend a lot of time trying to get this to work. (we need to fix this!) h2. Third-party libraries - JSE TBD h2. Third-party libraries - OSGI Third-party libraries often rely on TCCL to load implementation classes in an extensible way. For example, the SDO API loads the HelperContext implementation in this way. In an OSGi environment there will not be a static dependency between the api bundle and the impl bundle so we need to fake it. Typically we do this by setting up the TCCL appropriately before the library us called. See ClassLoaderContext which help us to set up a multi-classloader configurations. Typically in OSGi one of the classloaders we pass in here will be the extensibiliy-equinox bundle classloader (the ServiceDiscoverer) as this bundles has a dynamic import which allows it to load any class in the runtime. h2. Tuscany Node API - JSE TBD h2. Tuscany Node API - OSGi There are a small number of Tuscany Jars you need to use in the app launcher in the OSGi environment tuscany-sca-api tuscany-node-api tuscany-node-launcher-equinox The node API has to load the node implementation and has a dynamic import in its manifest DynamicImport-Package: org.apache.tuscany.sca.node.impl,org.apache.tuscany.sca.extensibility h2. SCA Client API - JSE Factory finder impl is injected into the API class by the implementation h2. SCA Client API - OSGi NodeFactory maintains a NodeProxy inner class that supports cross-classloader calls. The calling client api will have been loaded by the app classloader but the underlying node will have been loaded by a bundle classloader. We need to bridge that gap. Change your notification preferences: http://cwiki.apache.org/confluence/users/viewnotifications.action