Jean,
Native libraries are linked with system classloader thus they are not re-loaded 
even if bundle is updated.

Cheers,
Lukasz

Wiadomość napisana przez Jean-Baptiste Onofré <[email protected]> w dniu 27 cze 
2013, o godz. 20:56:

> Not sure I follow you:
> 
> "
> When a class loaded by a bundle's class loader attempts to load a native
> library, by calling System.loadLibrary, the findLibrary method of the 
> bundle’s class loader must be called to return the file path in which the 
> Framework has made the requested native library available. The parameter to 
> the findLibrary method is the name of the library in operating system 
> independent form, like http. The bundle class loader can use the 
> mapLibraryName method from the VM to map this name to an operating system 
> dependent name, like libhttp.so.
> "
> As we have a classloader per bundle, it's loaded at each bundle startup.
> 
> Regards
> JB
> 
> On 06/27/2013 08:05 PM, Łukasz Dywicki wrote:
>> Dear all,
>> As OSGi core spec says - native libraries are loaded once and they are
>> linked with classloader. Due the fact that bundle classloader only find
>> the native library for system classloader which performs load the DLL/SO
>> file is always loaded only once and remains in memory untill JVM shutdown.
>> 
>> For details see OSGi 5 Core Spec section 3.10, especially paragraph 3.10.2.
>> 
>> Czheers,
>> Łukasz Dywicki
>> --
>> [email protected] <mailto:[email protected]>
>> Twitter: ldywicki
>> Blog: http://dywicki.pl
>> Code-House - http://code-house.org
>> 
>> Wiadomość napisana przez CLEMENT Jean-Philippe
>> <[email protected]
>> <mailto:[email protected]>> w dniu 27 cze 2013, o
>> godz. 17:04:
>> 
>>> From what I understand BundleActivator warns when un bundle is
>>> started/stopped, which is not exactly the usecase I would like.
>>> 
>>> The .so lib must be loaded once. The best thing would be to obtain an
>>> event stating the bundle is installed so I may load the lib.
>>> 
>>> For the moment I added a class with a static part. I load the lib when
>>> that class is loaded by the classloader, which is not very good but
>>> does the job. I also put the bundle as singleton for extra protection.
>>> 
>>> JP
>>> 
>>> [@@ OPEN @@]
>>> 
>>> -----Message d'origine-----
>>> De : Jean-Baptiste Onofré [mailto:[email protected] <http://nanthrax.net>]
>>> Envoyé : jeudi 27 juin 2013 16:15
>>> À : [email protected] <mailto:[email protected]>
>>> Objet : Re: How to call a code only once
>>> 
>>> Hi JP,
>>> 
>>> you can control the loading in the BundleActivator.
>>> 
>>> Regards
>>> JB
>>> 
>>> On 06/27/2013 10:45 AM, CLEMENT Jean-Philippe wrote:
>>>> Dear Karaf,
>>>> 
>>>> I have a bundle which loads .so libraries. I would like this code to
>>>> run once. What is the easiest way to do so?
>>>> 
>>>> Best regards,
>>>> JP
>>>> 
>>> 
>>> --
>>> Jean-Baptiste Onofré
>>> [email protected] <mailto:[email protected]>
>>> http://blog.nanthrax.net
>>> Talend - http://www.talend.com
>> 
> 
> -- 
> Jean-Baptiste Onofré
> [email protected]
> http://blog.nanthrax.net
> Talend - http://www.talend.com

Reply via email to