karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1458718 - /karaf/branches/karaf-2.3.x/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java
Date Wed, 20 Mar 2013 10:19:38 GMT
Author: gnodet
Date: Wed Mar 20 10:19:38 2013
New Revision: 1458718

URL: http://svn.apache.org/r1458718
Log:
[KARAF-2244] BundleWatcher should wait for refresh to be finished before updating another
bundle

Modified:
    karaf/branches/karaf-2.3.x/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java

Modified: karaf/branches/karaf-2.3.x/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java?rev=1458718&r1=1458717&r2=1458718&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java
(original)
+++ karaf/branches/karaf-2.3.x/shell/dev/src/main/java/org/apache/karaf/shell/dev/watch/BundleWatcher.java
Wed Mar 20 10:19:38 2013
@@ -27,6 +27,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -41,7 +42,10 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleListener;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.wiring.FrameworkWiring;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.packageadmin.PackageAdmin;
@@ -117,15 +121,17 @@ public class BundleWatcher implements Ru
                         logger.error("Error updating bundle.", ex);
                     }
                 }
-                ServiceReference ref = null;
                 try {
-                    ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
-                    PackageAdmin pa = (PackageAdmin) getBundleContext().getService(ref);
-                    pa.refreshPackages(updated.toArray(new Bundle[updated.size()]));
-                } finally {
-                    if (ref != null) {
-                        getBundleContext().ungetService(ref);
-                    }
+                    final CountDownLatch latch = new CountDownLatch(1);
+                    FrameworkWiring wiring = getBundleContext().getBundle(0).adapt(FrameworkWiring.class);
+                    wiring.refreshBundles(updated, new FrameworkListener() {
+                        public void frameworkEvent(FrameworkEvent event) {
+                            latch.countDown();
+                        }
+                    });
+                    latch.await();
+                } catch (InterruptedException e) {
+                    running.set(false);
                 }
             }
             try {



Mime
View raw message