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, Apr 9, 2009 at 4:14 PM, Pierre De Rop
<pierre.de_...@alcatel-lucent.fr> 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 fires the event.
>
> Is is a normal behavior ?
> So far, I was fairly certain that this event was only fired after invoking
> PackageAdmin.refreshPackages() methods.
> Actually, we are using our own bundle installer, which install/updates our
> bundles.
> And our bundle installer does the following, when it updates a bundle:
>
> class BundleInstaller implements FrameworkListener {
>  boolean refreshing = false;
>
>  void update(Bundle([] bundles) {
>   for (Bundle b : bundles) {
>      b.stop();
>      b.update(); // May fire a PACKAGES_REFRESHED event
>   }
>
>   synchronized (this) {
>     this.refreshing = true;
>   }
>   *packageAdmin.refresh(null); // asynchronous *
>
>   synchronized (this) {
>     *while (refreshing) wait(); *// ensure that all bundles are refreshed
> before restarting updated bundles.
>   }
>
>   for (Bundle b : bundles) {
>      b.start();
>   }
>  }
>
>  // Here, I listen to the framework event "PACKAGES_REFRESHED"
>  void frameworkEvent(FrameworkEvent event) {
>    switch (event.getType()) {
>       case FrameworkEvent.PACKAGES_REFRESHED:
>       synchronized (this) {
>          this.refreshing = false;
>          notify();
>       }
>     }
>  }
> }
>
> The problem here, is that the first loop of my method "update" invokes
> Bundle.update(), which may fire some unexpected PACKAGES_REFRESHED events
> ...
> I'm expecting only one, and my waiting loop exits after the first event
> received.
>
> So, what can I do in order to ensure that the
> PackageAdmin.refreshPackages(null) method has completed ?
>
> Thanks in advance;
> /pierre
>
>
>
>



-- 
Karl Pauls
karlpa...@gmail.com

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

Reply via email to