Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-11 Thread Pierre De Rop
Ok, thanks for the feedback. /pierre Richard S. Hall wrote: Yes, that does make sense. You are correct that the listeners are snapshot'ed, so in this case you are more likely to see your own event. However, there is no guarantee that someone else didn't sneak in and make a request to

Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-10 Thread Karl Pauls
No. You don't need to worry about ClassCastExceptions as your bundle will be wired to the old revision of the bundle. Unless you don't import what you export :-) See http://felix.apache.org/site/apache-felix-osgi-faq.html for more on the why. regards, Karl On Fri, Apr 10, 2009 at 7:40 AM,

Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-10 Thread Pierre De Rop
All right, I will try to import what I export. Thanks for your suggestion; /pierre Karl Pauls wrote: No. You don't need to worry about ClassCastExceptions as your bundle will be wired to the old revision of the bundle. Unless you don't import what you export :-) See

Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-10 Thread Richard S. Hall
On 4/10/09 1:40 AM, Pierre De Rop wrote: Richard, Before posting an issue into osgi-dev about this subject, I would like to check with you if it really makes sense to wait for the PACKAGES_REFRESHED ... Here is my use case: * bundle B1 exports B1Service * B2 imports and implements

Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-10 Thread Pierre De Rop
I have looked into the code of the package admin implementation, from the trunk, and I think I have found a working solution for my problem. Indeed, in the org.apache.felix.deploymentadmin.spi.StartBundleCommand class, the method execute just does the following, when refreshing synchronously:

Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-10 Thread Pierre De Rop
I'm sorry, in the previous sample code, I forgot to remove the fwk listener after the refresh, so here is the good fix: public class BundleInstaller { BundleContext _bctx; PackageAdmin _pkgAdmin; // ... void update(Bundle[] bundles) { for (Bundle b : bundles) { b.stop();

Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-10 Thread Richard S. Hall
Yes, that does make sense. You are correct that the listeners are snapshot'ed, so in this case you are more likely to see your own event. However, there is no guarantee that someone else didn't sneak in and make a request to PackageAdmin before you could do it. :-( But, assuming you know what

Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-09 Thread Karl Pauls
In case that a bundle is not used by other bundles it will be refreshed automagically (this is allowed by the spec) when it is updated. Unfortunately, I cant think of a way to achieve what you want to do off the top of my head - might be something to discuss at osgi-dev... regards, Karl On Thu,

Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-09 Thread Richard S. Hall
On 4/9/09 10:14 AM, Pierre De Rop wrote: Hello everyone, I just discovered that invoking Bundle.update() method may fire a framework event PACKAGES_REFRESHED event. In the trunk, I see, in Felix.java, line 1691, that the update method may invoke the refreshPackage(null) method, which then

Re: Why Bundle.update() method fires a PACKAGES_REFRESHED event ?

2009-04-09 Thread Pierre De Rop
Richard, Before posting an issue into osgi-dev about this subject, I would like to check with you if it really makes sense to wait for the PACKAGES_REFRESHED ... Here is my use case: * bundle B1 exports B1Service * B2 imports and implements B1Service. When B2 starts: it registers