aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject svn commit: r800349 - /websites/staging/aries/trunk/content/modules/spi-fly.html
Date Fri, 16 Dec 2011 12:30:39 GMT
Author: buildbot
Date: Fri Dec 16 12:30:39 2011
New Revision: 800349

Staging update by buildbot


Modified: websites/staging/aries/trunk/content/modules/spi-fly.html
--- websites/staging/aries/trunk/content/modules/spi-fly.html (original)
+++ websites/staging/aries/trunk/content/modules/spi-fly.html Fri Dec 16 12:30:39 2011
@@ -254,6 +254,22 @@
 <p>This page describes the SPI Fly component.
 The SPI Fly component is aimed at providing general support for the JRE SPI
 mechanism (including the usage of <tt>java.util.ServiceLoader</tt> and <tt>META-INF/services</tt>)
in OSGi.</p>
+<h2 id="the_problem">The Problem</h2>
+<p><tt>java.util.ServiceLoader.load()</tt> and other similar methods such
+<tt>sun.misc.Service.providers()</tt>, but also other static finder methods such
as the 
+<tt>FactoryFinder.find()</tt> methods try to locate service implementations by
looking for 
+resources in the META-INF/services directory of all the jars visible to the 
+<strong><em>Thread Context ClassLoader</em></strong>.</p>
+<p>There are a number of issues with this approach in OSGi:</p>
+<li>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. </li>
+<li>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.</li>
+<li>Instantiating an SPI provider generally requires access to internal implementation
classes, by exporting these classes an implementing bundle would break its encapsulation.
+<li>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.</li>
+<li>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.</li>
+<p>The SPI Fly project makes it possible to use existing code that uses ServiceLoader.load()
+and other methods that </p>
 <p>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: <a href=""></a></p>
 <p>The code can be found in

View raw message