felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r418726 - in /incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework: ExportedPackageImpl.java Felix.java PackageAdminImpl.java
Date Mon, 03 Jul 2006 09:52:10 GMT
Author: rickhall
Date: Mon Jul  3 02:52:07 2006
New Revision: 418726

URL: http://svn.apache.org/viewvc?rev=418726&view=rev
Log:
Modified PackageAdmin.getExportedPackage() to return the highest version
as per the spec. This resulted in removing a method from Felix and slightly
cleaning up the ExportedPackageImpl class.

Modified:
    incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
    incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
    incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java?rev=418726&r1=418725&r2=418726&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
Mon Jul  3 02:52:07 2006
@@ -35,7 +35,7 @@
         m_felix = felix;
         m_exporter = exporter;
         m_name = name;
-        m_version = version;
+        m_version = (version == null) ? Version.emptyVersion : version;
     }
 
     public Bundle getExportingBundle()
@@ -82,14 +82,7 @@
     {
         if (m_versionString == null)
         {
-            if (m_version == null)
-            {
-                m_versionString = "0.0.0";
-            }
-            else
-            {
-                m_versionString = m_version.toString();
-            }
+            m_versionString = m_version.toString();
         }
         return m_versionString;
     }

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java?rev=418726&r1=418725&r2=418726&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
Mon Jul  3 02:52:07 2006
@@ -2569,23 +2569,7 @@
     }
 
     /**
-     * Returns the exported package associated with the specified
-     * package name. This is used by the PackageAdmin service
-     * implementation.
-     *
-     * @param name The name of the exported package to find.
-     * @return The exported package or null if no matching package was found.
-    **/
-    protected ExportedPackage getExportedPackage(String name)
-    {
-        ExportedPackage[] pkgs = getExportedPackages(name);
-        // There can be multiple versions of the same package exported,
-        // so we will just return the first one.
-        return ((pkgs != null) && (pkgs.length != 0)) ? pkgs[0] : null;
-    }
-
-    /**
-     * Returns the exported package associated with the specified
+     * Returns the exported packages associated with the specified
      * package name. This is used by the PackageAdmin service
      * implementation.
      *

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java?rev=418726&r1=418725&r2=418726&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
Mon Jul  3 02:52:07 2006
@@ -102,16 +102,44 @@
         return bundles;
     }
 
+    public int getBundleType(Bundle bundle)
+    {
+        return 0;
+    }
+
     /**
      * Returns the exported package associated with the specified
-     * package name.
+     * package name. If there are more than one version of the package
+     * being exported, then the highest version is returned.
      *
      * @param name the name of the exported package to find.
      * @return the exported package or null if no matching package was found.
     **/
     public ExportedPackage getExportedPackage(String name)
     {
-        return m_felix.getExportedPackage(name);
+        // Get all versions of the exported package.
+        ExportedPackage[] pkgs = m_felix.getExportedPackages(name);
+        // If there are no versions exported, then return null.
+        if ((pkgs == null) || (pkgs.length == 0))
+        {
+            return null;
+        }
+        // Sort the exported versions.
+        Arrays.sort(pkgs, new Comparator() {
+            public int compare(Object o1, Object o2)
+            {
+                // Reverse arguments to sort in descending order.
+                return ((ExportedPackage) o2).getVersion().compareTo(
+                    ((ExportedPackage) o1).getVersion());
+            }
+        });
+        // Return the highest version.
+        return pkgs[0];
+    }
+
+    public ExportedPackage[] getExportedPackages(String name)
+    {
+        return m_felix.getExportedPackages(name);
     }
 
     /**
@@ -126,11 +154,6 @@
         return m_felix.getExportedPackages(b);
     }
 
-    public ExportedPackage[] getExportedPackages(String name)
-    {
-        return m_felix.getExportedPackages(name);
-    }
-
     /**
      * The OSGi specification states that refreshing packages is
      * asynchronous; this method simply notifies the package admin
@@ -233,11 +256,5 @@
     {
         // TODO: Implement PackageAdmin.getHosts()
         return null;
-    }
-
-    public int getBundleType(Bundle bundle)
-    {
-        // TODO: Implement PackageAdmin.getBundleType()
-        return 0;
     }
 }



Mime
View raw message