felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r422679 - in /incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework: BundleInfo.java ExportedPackageImpl.java Felix.java
Date Mon, 17 Jul 2006 11:06:59 GMT
Author: rickhall
Date: Mon Jul 17 04:06:59 2006
New Revision: 422679

URL: http://svn.apache.org/viewvc?rev=422679&view=rev
Log:
Fixed an incorrect interpretation of the spec where we were equating
"is removal pending" with "is stale" for exported packages, but this is
not correct. A package is removal pending if it has been updated or
uninstalled, while a package is stale if it has been refreshed and is
no longer valid.

Modified:
    incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/BundleInfo.java
    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

Modified: incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/BundleInfo.java
URL: http://svn.apache.org/viewvc/incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/BundleInfo.java?rev=422679&r1=422678&r2=422679&view=diff
==============================================================================
--- incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/BundleInfo.java
(original)
+++ incubator/felix/trunk/org.apache.felix.framework/src/main/java/org/apache/felix/framework/BundleInfo.java
Mon Jul 17 04:06:59 2006
@@ -24,6 +24,9 @@
 
 class BundleInfo
 {
+    private static final int REMOVAL_PENDING_FLAG = 1;
+    private static final int STALE_FLAG = 2;
+
     private Logger m_logger = null;
     private BundleArchive m_archive = null;
     private IModule[] m_modules = null;
@@ -31,9 +34,11 @@
     private long m_modified = 0;
     private BundleActivator m_activator = null;
     private BundleContext m_context = null;
-    // Indicates that the bundle was either updated
-    // or uninstalled and is waiting to be removed or refreshed.
-    private boolean m_removalPending = false;
+    // Indicates that the bundle was either updated or
+    // uninstalled and is waiting to be removed or refreshed,
+    // or whether the bundle is stale because it was already
+    // refreshed.
+    private int m_removalState = 0;
 
     // Used for bundle locking.
     private int m_lockCount = 0;
@@ -47,7 +52,7 @@
         m_modules = (module == null) ? new IModule[0] : new IModule[] { module };
 
         m_state = Bundle.INSTALLED;
-        m_removalPending = false;
+        m_removalState = 0;
         m_activator = null;
         m_context = null;
     }
@@ -302,12 +307,22 @@
 
     public boolean isRemovalPending()
     {
-        return m_removalPending;
+        return (m_removalState & REMOVAL_PENDING_FLAG) != 0;
     }
 
     public void setRemovalPending()
     {
-        m_removalPending = true;
+        m_removalState = (m_removalState | REMOVAL_PENDING_FLAG);
+    }
+
+    public boolean isStale()
+    {
+        return (m_removalState & STALE_FLAG) != 0;
+    }
+
+    public void setStale()
+    {
+        m_removalState = (m_removalState | STALE_FLAG | REMOVAL_PENDING_FLAG);
     }
 
     //

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=422679&r1=422678&r2=422679&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 17 04:06:59 2006
@@ -40,33 +40,18 @@
 
     public Bundle getExportingBundle()
     {
-        // If remove is pending due to a bundle update, then
-        // return null per the spec.
-        if (m_exporter.getInfo().isRemovalPending())
+        // If the package is stale, then return null per the spec.
+        if (m_exporter.getInfo().isStale())
         {
             return null;
         }
         return m_exporter;
     }
 
-    /**
-     * Returns the exporting bundle whether the package is state or
-     * not. This is called internally to get access to the exporting
-     * bundle during a refresh operation, which is not possible using
-     * <tt>getExportingBundle</tt> since the specification says that
-     * method must return <tt>null</tt> for stale packages.
-     * @return the exporting bundle for the package.
-    **/
-    protected Bundle getExportingBundleInternal()
-    {
-        return m_exporter;
-    }
-    
     public Bundle[] getImportingBundles()
     {
-        // If remove is pending due to a bundle update, then
-        // return null per the spec.
-        if (m_exporter.getInfo().isRemovalPending())
+        // If the package is stale, then return null per the spec.
+        if (m_exporter.getInfo().isStale())
         {
             return null;
         }

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=422679&r1=422678&r2=422679&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 17 04:06:59 2006
@@ -2626,11 +2626,9 @@
 
     protected Bundle[] getImportingBundles(ExportedPackage ep)
     {
-        // Get exporting bundle; we need to use this internal
-        // method because the spec says ep.getExportingBundle()
-        // should return null if the package is stale.
+        // Get exporting bundle.
         BundleImpl exporter = (BundleImpl)
-            ((ExportedPackageImpl) ep).getExportingBundleInternal();
+            ((ExportedPackage) ep).getExportingBundle();
         BundleInfo exporterInfo = exporter.getInfo();
 
         // Create list for storing importing bundles.
@@ -3648,6 +3646,9 @@
             try
             {
                 BundleInfo info = m_bundle.getInfo();
+
+                // Mark the bundle as stale.
+                info.setStale();
 
                 // Remove or purge the bundle depending on its
                 // current state.



Mime
View raw message