felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Achim Nierbeck <bcanh...@googlemail.com>
Subject Re: How to make java.util.ServiceLoader work?
Date Sat, 08 Sep 2012 22:42:05 GMT
Hi,

just the other day we had a similar discussion at ops4j.
Now the OPS4j base jars support spi with a little SafeServiceLoader
which might fit your need. Take a look at [1]


regards, Achim

[1] - http://team.ops4j.org/wiki/display/base/Base



2012/9/8 Martin Lichtin <lichtin@yahoo.com>:
> Hi David
>
> Thanks! I actually came across SPI-Fly before posting, but it seemed like
> a "big thing" to introduce at the current situation with my project.
>
> What I would like in the short term is to inline the library (2 artifacts)
> and "fix" some of the classes, ie. provide my own code for them.
> I think it can be achieved with
>
> <Embed-Dependency>scope=compile|runtime;artifactId=a1|a2;inline=true;inline=!**/SP.class;inline=!**/RP*.class</Embed-Dependency>
>
> However, the instruction
>
> inline=!**/SP.class;inline=!**/RP*.class
>
> to exclude a total of four classes does not work quite right.
> I also tried
>
> inline=!**/SP.class|**/RP*.class
>
> without any luck.
>
> Martin
>
>
>
> -------- Original Message --------
> Subject: Re: How to make java.util.ServiceLoader work?
> From: David Bosschaert <david.bosschaert@gmail.com>
> To: users@felix.apache.org, Martin Lichtin <lichtin@yahoo.com>
> Date: 9/7/2012 4:42 PM
>
>> Hi Martin,
>>
>> You may want to take a look at the SPI Fly component in Apache Aries:
>> http://aries.apache.org/modules/spi-fly.html - this allows you to do
>> this relatively easily.
>> Additionally, the OSGi Enterprise Spec 5 chapter 133 covers this [1].
>>
>> Cheers,
>>
>> David
>>
>> [1] www.osgi.org/Download/Release5
>>
>> On 7 September 2012 14:50, Martin Lichtin <lichtin@yahoo.com> wrote:
>>>
>>> Hi
>>>
>>>  From an OSGi bundle I need to call a library that itself uses
>>> ServiceLoader to lookup/load a service provider class.
>>>
>>> This does not seem to work, however.
>>> java.util.ServiceLoader.load(x.api.z) returns no providers.
>>>
>>> I embedded the library, so both file META-INF/services/x.api.z and class
>>> x.spi.z are part of my bundle JAR.
>>> I thought this would be enough to get ServiceLoader to work, but no :-(
>>>
>>> Any ideas?
>>>
>>>
>>> I already tried
>>>
>>>           ClassLoader thread =
>>> Thread.currentThread().getContextClassLoader();
>>>
>>> Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
>>>           <call-library>
>>>           Thread.currentThread().setContextClassLoader(thread);
>>>
>>>
>>> in case TCCL would be the problem, but that didn't help.
>>>
>>> Martin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>



-- 

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead
OPS4J Pax for Vaadin
<http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project
Lead
blog <http://notizblog.nierbeck.de/>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message