[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] OSGi/Equinox and Java SPI

Have you tried adding:
DynamicImport-Package: *

...to the manifest of the bundle containing the calls to ServiceLoader (I suppose that's the third-party library you have edited the manifest of so it can run on OSGi, right)?

With this entry you are basically telling Equinox that it is OK to add entries to the bundle imports as needed during runtime so you don't need to know all of them in advance. Packages will still need to be exported by the bundles supplying the additional Charset. Adding this entry will allow them to become available to your bundle (and that should make them discoverable by ServiceLoader).

Let me know how that goes,
Eduardo Born

2010/9/9 Michael Furtak <mfurtak@xxxxxxx>

Hi all,


I am running into some issues with a 3rd party library, and I want to be sure I am correctly understanding the situation. My system is Equinox-based, and I am attempting to introduce a bundle for document processing. That JAR needs to introduce support for character sets which are not included in Java by default. The Charset class uses Java’s SPI pattern (http://java.sun.com/developer/technicalArticles/javase/extensible/index.html) to discover additional Charset implementations at runtime. That JAR has been altered to provide an OSGi manifest, but its META-INF/services/ java.nio.charset.spi.CharsetProvider file remains in its original location.


The issue is that the SPI mechanism fails completely under OSGi/Equinox. When I look at the implementation in java.nio.charset.Charset, it uses the System ClassLoader when trying to find the appropriate resources. Clearly, that doesn’t bode well for interaction with OSGi bundles.


That leaves me with a couple questions:

1) Is the general incompatibility between OSGi/Equinox bundles and SPI a known issue?

2) Is there a workaround I can use to get things working?




+  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +

Michael Furtak

Charles River Analytics Inc.

617.491.3474 x534




THIS MESSAGE IS INTENDED FOR THE USE OF THE PERSON TO WHOM IT IS ADDRESSED. IT MAY CONTAIN INFORMATION THAT IS PRIVILEGED, CONFIDENTIAL AND EXEMPT FROM DISCLOSURE UNDER APPLICABLE LAW. If you are not the intended recipient, your use of this message for any purpose is strictly prohibited. If you have received this communication in error, please delete the message and notify the sender so that we may correct our records.


equinox-dev mailing list