Hi,

you are right, for instance a singleton (static) is local to one classloader.

In OSGi, using static import (Import-Package), you have one classloader (with delegation) per bundle.
Using service, it's different.

In that case, you should use services.

Regards
JB

On 08/26/2011 04:39 PM, DonLuigi wrote:
I was under the impression that because in OSGi each bundle has its own class
loader, static variables are initialized once per classloader.

When I try to instantiate class A from bundle A in bundle B, static
variables are left over from initialization when class was loaded in bundle
A.

Classloaders are indeed different for class A instantiated in bundle A and
bundle B.

The reason I am doing this is because I need a “context” per bundle that is
used by common code exported by bundle A and used by other bundles, and I
don’t want to drag that “context” all over the place and pass it to every
call.

So my question is: is there any static way of  doing this?

Thanks

--
View this message in context: 
http://karaf.922171.n3.nabble.com/Static-variables-tp3287037p3287037.html
Sent from the Karaf - User mailing list archive at Nabble.com.

--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to