Return-Path: X-Original-To: apmail-aries-commits-archive@www.apache.org Delivered-To: apmail-aries-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 80F69910E for ; Fri, 16 Dec 2011 12:30:42 +0000 (UTC) Received: (qmail 64889 invoked by uid 500); 16 Dec 2011 12:30:42 -0000 Delivered-To: apmail-aries-commits-archive@aries.apache.org Received: (qmail 64835 invoked by uid 500); 16 Dec 2011 12:30:42 -0000 Mailing-List: contact commits-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list commits@aries.apache.org Received: (qmail 64827 invoked by uid 99); 16 Dec 2011 12:30:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Dec 2011 12:30:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Dec 2011 12:30:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5AC5823889ED; Fri, 16 Dec 2011 12:30:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1215110 - /aries/site/trunk/content/modules/spi-fly.mdtext Date: Fri, 16 Dec 2011 12:30:14 -0000 To: commits@aries.apache.org From: davidb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111216123014.5AC5823889ED@eris.apache.org> Author: davidb Date: Fri Dec 16 12:30:13 2011 New Revision: 1215110 URL: http://svn.apache.org/viewvc?rev=1215110&view=rev Log: Additional documentation Modified: aries/site/trunk/content/modules/spi-fly.mdtext Modified: aries/site/trunk/content/modules/spi-fly.mdtext URL: http://svn.apache.org/viewvc/aries/site/trunk/content/modules/spi-fly.mdtext?rev=1215110&r1=1215109&r2=1215110&view=diff ============================================================================== --- aries/site/trunk/content/modules/spi-fly.mdtext (original) +++ aries/site/trunk/content/modules/spi-fly.mdtext Fri Dec 16 12:30:13 2011 @@ -6,6 +6,25 @@ This page describes the SPI Fly componen The SPI Fly component is aimed at providing general support for the JRE SPI mechanism (including the usage of java.util.ServiceLoader and META-INF/services) in OSGi. + +##The Problem## +java.util.ServiceLoader.load() and other similar methods such as +sun.misc.Service.providers(), but also other static finder methods such as the +FactoryFinder.find() methods try to locate service implementations by looking for +resources in the META-INF/services directory of all the jars visible to the +***Thread Context ClassLoader***. + +There are a number of issues with this approach in OSGi: + + 1. The Thread Context Classloader is not defined in general in an OSGi context. It can and has to be set by the caller and OSGi cannot enforce that. + 2. A bundle can't Import-Package META-INF/services as potentially many bundles will contain this pseudo-package and the OSGi framework will only bind a single exporter to an importer for a given package. + 3. Instantiating an SPI provider generally requires access to internal implementation classes, by exporting these classes an implementing bundle would break its encapsulation. + 4. Even if an implementation class was exported, importing this class in a consumer bundle would bind it to the specific implementation package provided, which violates the principle of loose coupling. + 5. Bundles have a dynamic life-cycle which means that provided services could disappear when a bundle is updated or uninstalled. The java.util.ServiceLoader API does not provide a mechanism to inform service consumers of such an event. + +The SPI Fly project makes it possible to use existing code that uses ServiceLoader.load() +and other methods that + There are currently standardization efforts ongoing in the OSGi Alliance for which the SPI-Fly project is a prototype. For more information, see RFC 167 in the OSGi Enterprise 4.4 EA draft: [http://www.osgi.org/download/osgi-early-draft-2011-05.pdf][1]