You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2008/10/24 12:33:54 UTC

svn commit: r707598 - /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java

Author: fmeschbe
Date: Fri Oct 24 03:33:53 2008
New Revision: 707598

URL: http://svn.apache.org/viewvc?rev=707598&view=rev
Log:
FELIX-793 get PackageAdmin before installing/update bundles and only
refresh the packages of the installed/updated bundle

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java?rev=707598&r1=707597&r2=707598&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java (original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java Fri Oct 24 03:33:53 2008
@@ -249,7 +249,7 @@
         Thread t = new InstallHelper( this, "Background Install " + bundleFile, bundleFile, refreshPackages )
         {
 
-            protected void doRun( InputStream bundleStream ) throws BundleException
+            protected Bundle doRun( InputStream bundleStream ) throws BundleException
             {
                 Bundle bundle = getBundleContext().installBundle( location, bundleStream );
 
@@ -266,6 +266,8 @@
                 {
                     bundle.start();
                 }
+                
+                return bundle;
             }
         };
 
@@ -279,9 +281,10 @@
             + bundle.getBundleId() + ")", bundleFile, refreshPackages )
         {
 
-            protected void doRun( InputStream bundleStream ) throws BundleException
+            protected Bundle doRun( InputStream bundleStream ) throws BundleException
             {
                 bundle.update( bundleStream );
+                return bundle;
             }
         };
 
@@ -309,7 +312,7 @@
         }
 
 
-        protected abstract void doRun( InputStream bundleStream ) throws BundleException;
+        protected abstract Bundle doRun( InputStream bundleStream ) throws BundleException;
 
 
         public void run()
@@ -321,28 +324,22 @@
             InputStream bundleStream = null;
             try
             {
+                // we need the package admin before we call the bundle
+                // installation or update, since we might be updating
+                // our selves in which case the bundle context will be
+                // invalid by the time we want to call the update
+                PackageAdmin pa = ( refreshPackages ) ? installAction.getPackageAdmin() : null;
+
                 bundleStream = new FileInputStream( bundleFile );
-                doRun( bundleStream );
+                Bundle bundle = doRun( bundleStream );
 
-                if ( refreshPackages )
+                if ( pa != null )
                 {
                     // wait for asynchronous bundle start tasks to finish
                     sleepSilently( 2000L );
 
-                    try
-                    {
-                        PackageAdmin pa = installAction.getPackageAdmin();
-                        if ( pa != null )
-                        {
-                            pa.refreshPackages( null );
-                        }
-                    }
-                    catch ( IllegalStateException ise )
-                    {
-                        // This exception is expected if the webconsole bundle
-                        // itself has just been updated. For now, we just
-                        // ignore this exception
-                    }
+                    pa.refreshPackages( new Bundle[]
+                        { bundle } );
                 }
             }
             catch ( IOException ioe )