felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r918442 - in /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core: BaseUpdateInstallHelper.java BundlesServlet.java InstallAction.java
Date Wed, 03 Mar 2010 12:27:15 GMT
Author: fmeschbe
Date: Wed Mar  3 12:27:14 2010
New Revision: 918442

URL: http://svn.apache.org/viewvc?rev=918442&view=rev
Log:
FELIX-2119 Prevent ClassDefNotFoundException if OBR API is not available: Refactoring the
BaseUpdateInstallHelper class to not extend the Thread class any more.

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BaseUpdateInstallHelper.java
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
    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/BaseUpdateInstallHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BaseUpdateInstallHelper.java?rev=918442&r1=918441&r2=918442&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BaseUpdateInstallHelper.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BaseUpdateInstallHelper.java
Wed Mar  3 12:27:14 2010
@@ -32,21 +32,28 @@
 import org.osgi.service.packageadmin.PackageAdmin;
 
 
-abstract class BaseUpdateInstallHelper extends Thread
+abstract class BaseUpdateInstallHelper
 {
 
     private final File bundleFile;
 
     private final boolean refreshPackages;
 
+    private Thread updateThread;
+
 
     BaseUpdateInstallHelper( String name, File bundleFile, boolean refreshPackages )
     {
-        super( name );
-        setDaemon( true );
-
         this.bundleFile = bundleFile;
         this.refreshPackages = refreshPackages;
+        this.updateThread = new Thread( name )
+        {
+            public void run()
+            {
+                BaseUpdateInstallHelper.this.run();
+            };
+        };
+        this.updateThread.setDaemon( true );
     }
 
 
@@ -83,11 +90,19 @@
         {
             IOUtils.closeQuietly( bundleStream );
         }
+    }
 
+
+    final void start()
+    {
+        if ( updateThread != null )
+        {
+            updateThread.start();
+        }
     }
 
 
-    public void run()
+    void run()
     {
         // wait some time for the request to settle
         sleepSilently( 500L );
@@ -126,6 +141,9 @@
             {
                 bundleFile.delete();
             }
+
+            // release update thread for GC
+            updateThread = null;
         }
     }
 
@@ -134,7 +152,7 @@
     {
         try
         {
-            sleep( msecs );
+            Thread.sleep( msecs );
         }
         catch ( InterruptedException ie )
         {

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java?rev=918442&r1=918441&r2=918442&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
Wed Mar  3 12:27:14 2010
@@ -95,7 +95,7 @@
     private boolean[] bootPkgWildcards;
 
     private ServiceRegistration configurationPrinter;
-    
+
     // templates
     private final String TEMPLATE_MAIN;
     private final String TEMPLATE_UPLOAD;
@@ -106,8 +106,8 @@
         super(NAME, TITLE, CSS);
 
         // load templates
-        TEMPLATE_MAIN = readTemplateFile( "/templates/bundles.html" ); 
-        TEMPLATE_UPLOAD = readTemplateFile( "/templates/bundles_upload.html" ); 
+        TEMPLATE_MAIN = readTemplateFile( "/templates/bundles.html" );
+        TEMPLATE_UPLOAD = readTemplateFile( "/templates/bundles_upload.html" );
     }
 
     /**
@@ -446,7 +446,7 @@
             StringWriter w = new StringWriter();
             writeJSON(w, reqInfo.bundle, pluginRoot, servicesRoot, request.getLocale() );
             vars.put( "__bundles__", w.toString());
-            
+
             response.getWriter().print(TEMPLATE_MAIN);
         }
     }
@@ -487,11 +487,11 @@
 
             jw.key( "status" );
             jw.value( statusLine );
-            
+
             // add raw status
             jw.key( "s" );
             jw.array();
-            for ( int i = 0; i < 5; i++ ) jw.value(status[i]); 
+            for ( int i = 0; i < 5; i++ ) jw.value(status[i]);
             jw.endArray();
 
             jw.key( "data" );
@@ -1279,7 +1279,7 @@
 
     private void update( final Bundle bundle )
     {
-        Thread t = new UpdateHelper( bundle, false )
+        UpdateHelper t = new UpdateHelper( bundle, false )
         {
             protected Logger getLog()
             {
@@ -1347,17 +1347,17 @@
     {
         return (RequestInfo)request.getAttribute( BundlesServlet.class.getName() );
     }
-    
+
     private final PackageAdmin getPackageAdmin()
     {
         return ( PackageAdmin ) getService( PackageAdmin.class.getName() );
     }
-    
+
     private final StartLevel getStartLevel()
     {
         return ( StartLevel ) getService( StartLevel.class.getName() );
     }
-    
+
     // TODO: may remove later, when BaseWebConsolePlugin is made to extend SimpleWebConsolePlugin
     private Logger log;
     Logger getLog()

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=918442&r1=918441&r2=918442&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
Wed Mar  3 12:27:14 2010
@@ -274,7 +274,8 @@
         final boolean doStart, final boolean refreshPackages )
     {
 
-        Thread t = new InstallHelper( getBundleContext(), bundleFile, location, startlevel,
doStart, refreshPackages )
+        InstallHelper t = new InstallHelper( getBundleContext(), bundleFile, location, startlevel,
doStart,
+            refreshPackages )
         {
             protected Logger getLog()
             {
@@ -303,7 +304,7 @@
 
     private void updateBackground( final Bundle bundle, final File bundleFile, final boolean
refreshPackages )
     {
-        Thread t = new UpdateHelper( bundle, bundleFile, refreshPackages )
+        UpdateHelper t = new UpdateHelper( bundle, bundleFile, refreshPackages )
         {
             protected Logger getLog()
             {



Mime
View raw message