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

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Mon Jul 6 10:05:21 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-07-06 10:05:20 -0400 (Mon, 06 Jul 2009)
New Revision: 90847

Added:
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/BundleInfo.java
Removed:
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/FrameworkException.java
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/BundleInfo.java
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
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java
Log:
Unify BundleInfo

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-06 13:40:20 UTC (rev 90846)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -25,7 +25,7 @@
 
 import java.net.URL;
 
-import org.jboss.osgi.spi.service.BundleInfo;
+import org.jboss.osgi.spi.BundleInfo;
 import org.jboss.osgi.spi.service.DeployerService;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -50,7 +50,7 @@
       this.context = context;
    }
 
-   public Bundle getBundle(BundleInfo info) throws BundleException
+   public Bundle getBundle(BundleInfo info)
    {
       DeployerService service = getDefaultDeployerService();
       return service.getBundle(info);

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-06 13:40:20 UTC (rev 90846)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -34,8 +34,8 @@
 import java.util.jar.Manifest;
 
 import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.spi.BundleInfo;
 import org.jboss.osgi.spi.management.ManagedBundleService;
-import org.jboss.osgi.spi.service.BundleInfo;
 import org.jboss.osgi.spi.service.DeployerService;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -84,10 +84,10 @@
          throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
 
       String version = attribs.getValue(Constants.BUNDLE_VERSION);
-      return new BundleInfoImpl(url, symbolicName, version);
+      return new BundleInfo(url, symbolicName, version);
    }
 
-   public Bundle getBundle(BundleInfo info) throws BundleException
+   public Bundle getBundle(BundleInfo info)
    {
       String symbolicName = info.getSymbolicName();
       String version = info.getVersion();
@@ -206,35 +206,4 @@
          log.log(LogService.LOG_DEBUG, "No ManagedBundleService. Cannot unregister managed bundle: " + bundle);
       }
    }
-
-   static class BundleInfoImpl implements BundleInfo
-   {
-      private URL location;
-      private String symbolicName;
-      private String version;
-
-      public BundleInfoImpl(URL location, String symbolicName, String version)
-      {
-         super();
-         this.location = location;
-         this.symbolicName = symbolicName;
-         this.version = version;
-      }
-
-      public URL getLocation()
-      {
-         return location;
-      }
-
-      public String getSymbolicName()
-      {
-         return symbolicName;
-      }
-
-      public String getVersion()
-      {
-         return version;
-      }
-
-   }
 }
\ No newline at end of file

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-06 13:40:20 UTC (rev 90846)
+++ projects/jboss-osgi/projects/bundles/hotdeploy/trunk/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -35,9 +35,10 @@
 import java.util.Set;
 
 import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.spi.service.BundleInfo;
+import org.jboss.osgi.spi.BundleInfo;
 import org.jboss.osgi.spi.service.DeployerService;
 import org.jboss.osgi.spi.service.DeploymentScannerService;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.ServiceReference;
@@ -172,7 +173,11 @@
       for (BundleInfo info : lastScan)
       {
          if (currScan.contains(info) == false)
-            diff.add(info);
+         {
+            Bundle bundle = deployer.getBundle(info);
+            if ((bundle.getState() & Bundle.INSTALLED) != 0)
+               diff.add(info);
+         }
       }
 
       if (traceBundles)
@@ -199,8 +204,10 @@
       // Detect NEW bundles that are not in the last scan  
       for (BundleInfo info : currScan)
       {
-         if (lastScan.contains(info) == false)
+         if (lastScan.contains(info) == false && deployer.getBundle(info) == null)
+         {
             diff.add(info);
+         }
       }
 
       if (traceBundles)

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-06 13:40:20 UTC (rev 90846)
+++ projects/jboss-osgi/projects/bundles/webconsole/trunk/src/main/java/org/jboss/osgi/service/webconsole/internal/plugins/InstallActionExt.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -29,7 +29,7 @@
 import java.net.URL;
 
 import org.apache.felix.webconsole.internal.core.InstallAction;
-import org.jboss.osgi.spi.service.BundleInfo;
+import org.jboss.osgi.spi.BundleInfo;
 import org.jboss.osgi.spi.service.DeployerService;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;

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-06 13:40:20 UTC (rev 90846)
+++ projects/jboss-osgi/projects/integration/jbossas/trunk/src/main/java/org/jboss/osgi/integration/jbossas/AbstractMicrocontainerService.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -53,8 +53,8 @@
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.osgi.spi.BundleInfo;
 import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
-import org.jboss.osgi.spi.service.BundleInfo;
 import org.jboss.osgi.spi.service.DeployerService;
 import org.jboss.osgi.spi.service.MicrocontainerService;
 import org.jboss.virtual.VFS;
@@ -133,10 +133,10 @@
          throw new BundleException("Cannot obtain Bundle-SymbolicName for: " + url);
 
       String version = attribs.getValue(Constants.BUNDLE_VERSION);
-      return new BundleInfoImpl(url, symbolicName, version);
+      return new BundleInfo(url, symbolicName, version);
    }
 
-   public Bundle getBundle(BundleInfo info) throws BundleException
+   public Bundle getBundle(BundleInfo info)
    {
       BundleContext context = getRegisteredBean(BundleContext.class, BEAN_SYSTEM_BUNDLE_CONTEXT);
       String symbolicName = info.getSymbolicName();
@@ -320,35 +320,4 @@
          super(name, actions, null, target);
       }
    }
-
-   static class BundleInfoImpl implements BundleInfo
-   {
-      private URL location;
-      private String symbolicName;
-      private String version;
-
-      public BundleInfoImpl(URL location, String symbolicName, String version)
-      {
-         super();
-         this.location = location;
-         this.symbolicName = symbolicName;
-         this.version = version;
-      }
-
-      public URL getLocation()
-      {
-         return location;
-      }
-
-      public String getSymbolicName()
-      {
-         return symbolicName;
-      }
-
-      public String getVersion()
-      {
-         return version;
-      }
-
-   }
 }
\ No newline at end of file

Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/BundleInfo.java (from rev 90833, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/BundleInfo.java)
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/BundleInfo.java	                        (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/BundleInfo.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.spi;
+
+//$Id$
+
+import java.net.URL;
+
+/**
+ * An abstraction of a bundle
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public class BundleInfo
+{
+   private URL location;
+   private String symbolicName;
+   private String version;
+
+   public BundleInfo(URL location, String symbolicName, String version)
+   {
+      this.symbolicName = symbolicName;
+      this.location = location;
+      this.version = (version != null ? version : "0.0.0");
+      
+      if (symbolicName == null)
+         throw new IllegalArgumentException("Symbolic name cannot be null");
+      if (location == null)
+         throw new IllegalArgumentException("Location cannot be null");
+   }
+
+   /**
+    * Get the bundle location
+    */
+   public URL getLocation()
+   {
+      return location;
+   }
+
+   /**
+    * Get the bundle symbolic name
+    */
+   public String getSymbolicName()
+   {
+      return symbolicName;
+   }
+
+   /**
+    * Get the bundle version
+    */
+   public String getVersion()
+   {
+      return version;
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (!(obj instanceof BundleInfo))
+         return false;
+      
+      BundleInfo other = (BundleInfo)obj;
+      return symbolicName.equals(other.symbolicName) && version.equals(other.version);
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return toString().hashCode();
+   }
+
+   @Override
+   public String toString()
+   {
+      return "[" + symbolicName + ":" + version + "]";
+   }
+}
\ No newline at end of file

Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/FrameworkException.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/FrameworkException.java	2009-07-06 13:40:20 UTC (rev 90846)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/FrameworkException.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi;
-
-// $Id$
-
-/**
- * An OSGi Framework Exception that should be thrown on unrecoverable errors.
- * 
- * @author thomas.diesler at jboss.com
- * @since 18-Jan-2009
- */
- at SuppressWarnings("serial")
-public class FrameworkException extends RuntimeException
-{
-  public FrameworkException(String message)
-  {
-    super(message);
-  }
-  
-  public FrameworkException(String message, Throwable cause)
-  {
-    super(message, cause);
-  }
-  
-  public FrameworkException(Throwable cause)
-  {
-    super(cause);
-  }
-}

Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/BundleInfo.java	2009-07-06 13:40:20 UTC (rev 90846)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/BundleInfo.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.spi.service;
-
-//$Id$
-
-import java.net.URL;
-
-
-/**
- * An abstraction of a bundle in the scan folder
- * 
- * @author thomas.diesler at jboss.com
- * @since 27-May-2009
- */
-public interface BundleInfo
-{
-   /**
-    * Get the bundle location
-    */
-   URL getLocation();
-
-   /**
-    * Get the bundle symbolic name
-    */
-   String getSymbolicName();
-
-   /**
-    * Get the bundle version
-    */
-   String getVersion();
-}
\ No newline at end of file

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-06 13:40:20 UTC (rev 90846)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeployerService.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -25,6 +25,7 @@
 
 import javax.management.ObjectName;
 
+import org.jboss.osgi.spi.BundleInfo;
 import org.jboss.osgi.spi.management.ObjectNameFactory;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
@@ -53,7 +54,7 @@
     * Get the installed bundle for the given bundle info 
     * @return null, if there is no bundle that matches the given bundle info
     */
-   Bundle getBundle(BundleInfo info) throws BundleException;
+   Bundle getBundle(BundleInfo info);
    
    /**
     * Deploy an array of bundles

Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java	2009-07-06 13:40:20 UTC (rev 90846)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/service/DeploymentScannerService.java	2009-07-06 14:05:20 UTC (rev 90847)
@@ -25,6 +25,8 @@
 
 import java.net.URL;
 
+import org.jboss.osgi.spi.BundleInfo;
+
 /**
  * A service that scans a directory location for new/removed bundles.
  * 




More information about the jboss-osgi-commits mailing list