[jboss-osgi-commits] JBoss-OSGI SVN: r90885 - in projects/jboss-osgi/projects: bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal and 3 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Tue Jul 7 05:01:38 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-07-07 05:01:37 -0400 (Tue, 07 Jul 2009)
New Revision: 90885

Modified:
   projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java
   projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
   projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
   projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java
   projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java
Log:
Add deploymentInfoCache

Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java	2009-07-07 09:00:56 UTC (rev 90884)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java	2009-07-07 09:01:37 UTC (rev 90885)
@@ -56,10 +56,10 @@
       return service.getBundle(info);
    }
 
-   public BundleInfo getBundleInfo(URL url) throws BundleException
+   public BundleInfo createBundleInfo(URL url) throws BundleException
    {
       DeployerService service = getDefaultDeployerService();
-      return service.getBundleInfo(url);
+      return service.createBundleInfo(url);
    }
 
    public void deploy(BundleInfo[] bundles) throws BundleException

Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java	2009-07-07 09:00:56 UTC (rev 90884)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java	2009-07-07 09:01:37 UTC (rev 90885)
@@ -63,7 +63,7 @@
       this.context = context;
    }
 
-   public BundleInfo getBundleInfo(URL url) throws BundleException
+   public BundleInfo createBundleInfo(URL url) throws BundleException
    {
       Manifest manifest;
       try

Modified: projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java	2009-07-07 09:00:56 UTC (rev 90884)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java	2009-07-07 09:01:37 UTC (rev 90885)
@@ -30,8 +30,10 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.jboss.osgi.common.log.LogServiceTracker;
@@ -64,6 +66,7 @@
    private ScannerThread scannerThread;
    private List<BundleInfo> lastScan = new ArrayList<BundleInfo>();
    private Set<ScanListener> listeners = new LinkedHashSet<ScanListener>();
+   private Map<String, BundleInfo> bundleInfoCache = new HashMap<String, BundleInfo>();
    private boolean traceBundles = false;
 
    public DeploymentScannerImpl(BundleContext context)
@@ -175,8 +178,12 @@
          if (currScan.contains(info) == false)
          {
             Bundle bundle = deployer.getBundle(info);
-            if ((bundle.getState() & Bundle.INSTALLED) != 0)
+            int state = bundle.getState();
+            if (state == Bundle.INSTALLED || state == Bundle.RESOLVED || state == Bundle.ACTIVE)
+            {
+               bundleInfoCache.remove(info.getLocation().toExternalForm());
                diff.add(info);
+            }
          }
       }
 
@@ -239,15 +246,21 @@
       {
          for (File file : listFiles)
          {
-            try
+            URL bundleURL = toURL(file);
+            BundleInfo info = bundleInfoCache.get(bundleURL.toExternalForm());
+            if (info == null)
             {
-               BundleInfo info = deployer.getBundleInfo(toURL(file));
-               bundles.add(info);
+               try
+               {
+                  info = deployer.createBundleInfo(bundleURL);
+                  bundleInfoCache.put(bundleURL.toExternalForm(), info);
+               }
+               catch (BundleException ex)
+               {
+                  log.log(LogService.LOG_WARNING, "Cannot obtain bundle info for: " + file);
+               }
             }
-            catch (BundleException ex)
-            {
-               log.log(LogService.LOG_WARNING, "Cannot obtain bundle info for: " + file);
-            }
+            bundles.add(info);
          }
       }
       

Modified: projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java	2009-07-07 09:00:56 UTC (rev 90884)
+++ projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java	2009-07-07 09:01:37 UTC (rev 90885)
@@ -66,7 +66,7 @@
             URL bundleURL = getBundleURL(bundleFile);
             
             service.deploy(bundleURL);
-            BundleInfo info = service.getBundleInfo(bundleURL);
+            BundleInfo info = service.createBundleInfo(bundleURL);
             Bundle bundle = service.getBundle(info);
 
             if (startlevel > 0)

Modified: projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java
===================================================================
--- projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java	2009-07-07 09:00:56 UTC (rev 90884)
+++ projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java	2009-07-07 09:01:37 UTC (rev 90885)
@@ -112,7 +112,7 @@
       return (T)getRegisteredBean(beanName);
    }
 
-   public BundleInfo getBundleInfo(URL url) throws BundleException
+   public BundleInfo createBundleInfo(URL url) throws BundleException
    {
       Manifest manifest;
       try

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java	2009-07-07 09:00:56 UTC (rev 90884)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java	2009-07-07 09:01:37 UTC (rev 90885)
@@ -46,9 +46,9 @@
    ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
 
    /**
-    * Get the bundle info for the given bundle URL
+    * Create the bundle info for the given bundle URL
     */
-   BundleInfo getBundleInfo(URL url) throws BundleException;
+   BundleInfo createBundleInfo(URL url) throws BundleException;
    
    /**
     * Get the installed bundle for the given bundle info 




More information about the jboss-osgi-commits mailing list