felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Munteanu <rmunt...@adobe.com>
Subject RE: Safe to retain references to OSGi bundles?
Date Thu, 18 Apr 2013 14:17:40 GMT
> >>> ...The reason I need to hold on to the bundle is to load classes
> >>> using that its classloader at a later point in time...
> >>
> >> Can't you do that using getClass().getClassLoader() on a class that's
> >> inside that bundle?
> >>
> >> I *think* keeping references to Bundle objects is fine if you track
> >> them with a BundleTracker, but that sounds somewhat complicated.
> >
> > I actually need to load a class using the classloader from a different bundle
> (B2) than the current one (B1).
> >
> > At some point in time B1 might be called on to load a class from B2 so the
> only way I knew how to  do this was to use bundle references and
> Bundle.getClass().
> >
> > Yes, it's done to appease a legacy bundle which is not OSGi-friendly :| .
> 
> I'd recommend using Bundle.loadClass() to load classes using another
> bundle's class loader.

That's what I meant, but for some reason I wrote Bundle.getClass() ...

> 
> As for using them as keys in maps, the Bundle interface extends
> Comparable so technically I don't see an issue there.

I see, that sounds good.

Thanks,

Robert 


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


Mime
View raw message