You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2011/06/10 19:09:07 UTC

svn commit: r1134391 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/

Author: rickhall
Date: Fri Jun 10 17:09:07 2011
New Revision: 1134391

URL: http://svn.apache.org/viewvc?rev=1134391&view=rev
Log:
Use standard approach for getting current bundle revision. (FELIX-2950)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java Fri Jun 10 17:09:07 2011
@@ -326,7 +326,7 @@ class BundleImpl implements Bundle
         if (locale.length() == 0)
         {
             result = new StringMap(
-                ((BundleRevisionImpl) getCurrentRevision()).getHeaders(), false);
+                ((BundleRevisionImpl) adapt(BundleRevision.class)).getHeaders(), false);
         }
 
         // If we have no result, try to get it from the cached headers.
@@ -363,7 +363,7 @@ class BundleImpl implements Bundle
         {
             // Get a modifiable copy of the raw headers.
             Map headers = new StringMap(
-                ((BundleRevisionImpl) getCurrentRevision()).getHeaders(), false);
+                ((BundleRevisionImpl) adapt(BundleRevision.class)).getHeaders(), false);
             // Assume for now that this will be the result.
             result = headers;
 
@@ -395,7 +395,7 @@ class BundleImpl implements Bundle
                 // Create ordered list of revisions to search for localization
                 // property resources.
                 List<BundleRevision> revisionList = createLocalizationRevisionList(
-                    (BundleRevisionImpl) getCurrentRevision());
+                    (BundleRevisionImpl) adapt(BundleRevision.class));
 
                 // Create ordered list of files to load properties from
                 List<String> resourceList = createLocalizationResourceList(basename, locale);
@@ -871,12 +871,12 @@ class BundleImpl implements Bundle
 
     public String getSymbolicName()
     {
-        return getCurrentRevision().getSymbolicName();
+        return adapt(BundleRevision.class).getSymbolicName();
     }
 
     public Version getVersion()
     {
-        return getCurrentRevision().getVersion();
+        return adapt(BundleRevision.class).getVersion();
     }
 
     public boolean hasPermission(Object obj)
@@ -1008,9 +1008,13 @@ class BundleImpl implements Bundle
             return (A) getFramework().adapt(FrameworkStartLevelImpl.class)
                 .createBundleStartLevel(this);
         }
+        else if (type == BundleRevision.class)
+        {
+            return (A) m_revisions.get(m_revisions.size() - 1);
+        }
         else if (type == BundleWiring.class)
         {
-            return (A) getCurrentRevision().getWiring();
+            return (A) m_revisions.get(m_revisions.size() - 1).getWiring();
         }
         return null;
     }
@@ -1027,7 +1031,7 @@ class BundleImpl implements Bundle
 
     public String toString()
     {
-        String sym = getCurrentRevision().getSymbolicName();
+        String sym = adapt(BundleRevision.class).getSymbolicName();
         if (sym != null)
         {
             return sym + " [" + getBundleId() +"]";
@@ -1079,16 +1083,6 @@ class BundleImpl implements Bundle
         return false;
     }
 
-    /**
-     * Returns the newest module, which corresponds to the last module
-     * in the module array.
-     * @return the newest module.
-    **/
-    synchronized BundleRevision getCurrentRevision()
-    {
-        return m_revisions.get(m_revisions.size() - 1);
-    }
-
     synchronized void revise(String location, InputStream is)
         throws Exception
     {
@@ -1191,7 +1185,7 @@ class BundleImpl implements Bundle
                 {
                     String sym = bundles[i].getSymbolicName();
                     Version ver = ((BundleRevisionImpl)
-                        ((BundleImpl) bundles[i]).getCurrentRevision()).getVersion();
+                        bundles[i].adapt(BundleRevision.class)).getVersion();
                     if ((symName != null) && (sym != null) && symName.equals(sym) && bundleVersion.equals(ver))
                     {
                         throw new BundleException(

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java Fri Jun 10 17:09:07 2011
@@ -42,20 +42,20 @@ public class BundleProtectionDomain exte
         super(
             new CodeSource(
                 Felix.m_secureAction.createURL(
-                    Felix.m_secureAction.createURL(null, "location:", new FakeURLStreamHandler()), 
+                    Felix.m_secureAction.createURL(null, "location:", new FakeURLStreamHandler()),
                     bundle._getLocation(),
                     new FakeURLStreamHandler()
-                    ), 
-                (Certificate[]) null), 
+                    ),
+                (Certificate[]) null),
             null);
         m_felix = new WeakReference(felix);
         m_bundle = new WeakReference(bundle);
-        m_revision = new WeakReference(bundle.getCurrentRevision());
+        m_revision = new WeakReference(bundle.adapt(BundleRevision.class));
         m_hashCode = bundle.hashCode();
         m_toString = "[" + bundle + "]";
     }
 
-    BundleRevision getRevision() 
+    BundleRevision getRevision()
     {
         return (BundleRevision) m_revision.get();
     }
@@ -63,14 +63,14 @@ public class BundleProtectionDomain exte
     public boolean implies(Permission permission)
     {
         Felix felix = (Felix) m_felix.get();
-        return (felix != null) ? 
+        return (felix != null) ?
             felix.impliesBundlePermission(this, permission, false) : false;
     }
 
     public boolean impliesDirect(Permission permission)
     {
         Felix felix = (Felix) m_felix.get();
-        return (felix != null) ? 
+        return (felix != null) ?
             felix.impliesBundlePermission(this, permission, true) : false;
     }
 

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java Fri Jun 10 17:09:07 2011
@@ -355,7 +355,7 @@ public class BundleRevisionImpl implemen
     public boolean isRemovalPending()
     {
         return (m_bundle.getState() == Bundle.UNINSTALLED)
-            || (this != ((BundleImpl) m_bundle).getCurrentRevision());
+            || (this != m_bundle.adapt(BundleRevision.class));
     }
 
     //

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java Fri Jun 10 17:09:07 2011
@@ -319,7 +319,7 @@ public class BundleWiringImpl implements
 
     public boolean isCurrent()
     {
-        return (((BundleImpl) m_revision.getBundle()).getCurrentRevision() == m_revision);
+        return (m_revision.getBundle().adapt(BundleRevision.class) == m_revision);
     }
 
     public boolean isInUse()
@@ -1519,8 +1519,8 @@ public class BundleWiringImpl implements
 
                                 int activationPolicy =
                                     ((BundleImpl) getBundle()).isDeclaredActivationPolicyUsed()
-                                    ? ((BundleRevisionImpl) ((BundleImpl) getBundle())
-                                        .getCurrentRevision()).getDeclaredActivationPolicy()
+                                    ? ((BundleRevisionImpl) getBundle()
+                                        .adapt(BundleRevision.class)).getDeclaredActivationPolicy()
                                     : EAGER_ACTIVATION;
 
                                 // If the revision is using deferred activation, then if

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java Fri Jun 10 17:09:07 2011
@@ -22,11 +22,12 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.*;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.wiring.BundleRevision;
 
 class EntryFilterEnumeration implements Enumeration
 {
-    private final BundleImpl m_bundle;
+    private final Bundle m_bundle;
     private final List<Enumeration> m_enumerations;
     private final List<BundleRevision> m_revisions;
     private int m_revisionIndex = 0;
@@ -38,11 +39,11 @@ class EntryFilterEnumeration implements 
     private final List<Object> m_nextEntries = new ArrayList(2);
 
     public EntryFilterEnumeration(
-        BundleImpl bundle, boolean includeFragments, String path,
+        Bundle bundle, boolean includeFragments, String path,
         String filePattern, boolean recurse, boolean isURLValues)
     {
         m_bundle = bundle;
-        BundleRevision br = m_bundle.getCurrentRevision();
+        BundleRevision br = m_bundle.adapt(BundleRevision.class);
         if (includeFragments
             && (br.getWiring() != null)
             && (((BundleWiringImpl) br.getWiring()).getFragments() != null))

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java Fri Jun 10 17:09:07 2011
@@ -304,7 +304,7 @@ class ExtensionManager extends URLStream
         }
 
         String directive = ManifestParser.parseExtensionBundleHeader((String)
-            ((BundleRevisionImpl) bundle.getCurrentRevision())
+            ((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                 .getHeaders().get(Constants.FRAGMENT_HOST));
 
         // We only support classpath extensions (not bootclasspath).
@@ -323,7 +323,7 @@ class ExtensionManager extends URLStream
             {
                 exports = ManifestParser.parseExportHeader(
                     m_logger, m_systemBundleRevision,
-                    (String) ((BundleRevisionImpl) bundle.getCurrentRevision())
+                    (String) ((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                         .getHeaders().get(Constants.EXPORT_PACKAGE),
                     m_systemBundleRevision.getSymbolicName(), m_systemBundleRevision.getVersion());
                 exports = aliasSymbolicName(exports);
@@ -334,7 +334,7 @@ class ExtensionManager extends URLStream
                     bundle,
                     Logger.LOG_ERROR,
                     "Error parsing extension bundle export statement: "
-                    + ((BundleRevisionImpl) bundle.getCurrentRevision())
+                    + ((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                         .getHeaders().get(Constants.EXPORT_PACKAGE), ex);
                 return;
             }
@@ -377,7 +377,7 @@ class ExtensionManager extends URLStream
     void startExtensionBundle(Felix felix, BundleImpl bundle)
     {
         String activatorClass = (String)
-            ((BundleRevisionImpl) bundle.getCurrentRevision())
+            ((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                 .getHeaders().get(FelixConstants.FELIX_EXTENSION_ACTIVATOR);
 
         if (activatorClass != null)
@@ -506,8 +506,8 @@ class ExtensionManager extends URLStream
         {
             try
             {
-                result = ((BundleRevisionImpl) ((BundleImpl)
-                    extBundle).getCurrentRevision()).getResourceLocal(path);
+                result = ((BundleRevisionImpl)
+                    extBundle.adapt(BundleRevision.class)).getResourceLocal(path);
             }
             catch (Exception ex)
             {

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Fri Jun 10 17:09:07 2011
@@ -683,7 +683,7 @@ public class Felix extends BundleImpl im
                 // state to be set to RESOLVED.
                 try
                 {
-                    m_resolver.resolve(getCurrentRevision());
+                    m_resolver.resolve(adapt(BundleRevision.class));
                 }
                 catch (ResolveException ex)
                 {
@@ -1527,7 +1527,7 @@ public class Felix extends BundleImpl im
         {
             throw new IllegalStateException("The bundle is uninstalled.");
         }
-        else if (Util.isFragment(bundle.getCurrentRevision()))
+        else if (Util.isFragment(bundle.adapt(BundleRevision.class)))
         {
             return null;
         }
@@ -1536,14 +1536,14 @@ public class Felix extends BundleImpl im
 //       searching if it fails. Perhaps we should attempt the resolve here
 //       and do the local searching here. This means we could get rid of
 //       resolve attempts in findClassOrResourceByDelegation().
-        if (bundle.getCurrentRevision().getWiring() == null)
+        if (bundle.adapt(BundleRevision.class).getWiring() == null)
         {
-            return ((BundleRevisionImpl) bundle.getCurrentRevision())
+            return ((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                 .getResourceLocal(name);
         }
         else
         {
-            return ((BundleWiringImpl) bundle.getCurrentRevision().getWiring())
+            return ((BundleWiringImpl) bundle.adapt(BundleRevision.class).getWiring())
                 .getResourceByDelegation(name);
         }
     }
@@ -1557,7 +1557,7 @@ public class Felix extends BundleImpl im
         {
             throw new IllegalStateException("The bundle is uninstalled.");
         }
-        else if (Util.isFragment(bundle.getCurrentRevision()))
+        else if (Util.isFragment(bundle.adapt(BundleRevision.class)))
         {
             return null;
         }
@@ -1566,14 +1566,14 @@ public class Felix extends BundleImpl im
 //       searching if it fails. Perhaps we should attempt the resolve here
 //       and do the local searching here. This means we could get rid of
 //       resolve attempts in findResourcesByDelegation().
-        if (bundle.getCurrentRevision().getWiring() == null)
+        if (bundle.adapt(BundleRevision.class).getWiring() == null)
         {
-            return ((BundleRevisionImpl) bundle.getCurrentRevision())
+            return ((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                 .getResourcesLocal(name);
         }
         else
         {
-            return ((BundleWiringImpl) bundle.getCurrentRevision().getWiring())
+            return ((BundleWiringImpl) bundle.adapt(BundleRevision.class).getWiring())
                 .getResourcesByDelegation(name);
         }
     }
@@ -1588,7 +1588,7 @@ public class Felix extends BundleImpl im
             throw new IllegalStateException("The bundle is uninstalled.");
         }
 
-        URL url = ((BundleRevisionImpl) bundle.getCurrentRevision()).getEntry(name);
+        URL url = ((BundleRevisionImpl) bundle.adapt(BundleRevision.class)).getEntry(name);
 
         // Some JAR files do not contain directory entries, so if
         // the entry wasn't found and is a directory, scan the entries
@@ -1718,7 +1718,7 @@ public class Felix extends BundleImpl im
         {
             throw new IllegalStateException("Bundle is uninstalled");
         }
-        else if (Util.isFragment(bundle.getCurrentRevision()))
+        else if (Util.isFragment(bundle.adapt(BundleRevision.class)))
         {
             throw new ClassNotFoundException("Fragments cannot load classes.");
         }
@@ -1737,7 +1737,7 @@ public class Felix extends BundleImpl im
             }
         }
         return ((BundleWiringImpl)
-            bundle.getCurrentRevision().getWiring()).getClassByDelegation(name);
+            bundle.adapt(BundleRevision.class).getWiring()).getClassByDelegation(name);
     }
 
     /**
@@ -1776,7 +1776,7 @@ public class Felix extends BundleImpl im
 
         // Record whether the bundle is using its declared activation policy.
         boolean wasDeferred = bundle.isDeclaredActivationPolicyUsed()
-            && (((BundleRevisionImpl) bundle.getCurrentRevision())
+            && (((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                 .getDeclaredActivationPolicy() == BundleRevisionImpl.LAZY_ACTIVATION);
         bundle.setDeclaredActivationPolicyUsed(
             (options & Bundle.START_ACTIVATION_POLICY) != 0);
@@ -1793,7 +1793,7 @@ public class Felix extends BundleImpl im
 
             // As per the OSGi spec, fragment bundles can not be started and must
             // throw a BundleException when there is an attempt to start one.
-            if (Util.isFragment(bundle.getCurrentRevision()))
+            if (Util.isFragment(bundle.adapt(BundleRevision.class)))
             {
                 throw new BundleException("Fragment bundles can not be started.");
             }
@@ -1898,9 +1898,9 @@ public class Felix extends BundleImpl im
             // If the bundle's activation policy is eager or activation has already
             // been triggered, then activate the bundle immediately.
             if (!bundle.isDeclaredActivationPolicyUsed()
-                || (((BundleRevisionImpl) bundle.getCurrentRevision())
+                || (((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                     .getDeclaredActivationPolicy() != BundleRevisionImpl.LAZY_ACTIVATION)
-                || ((BundleWiringImpl) bundle.getCurrentRevision().getWiring())
+                || ((BundleWiringImpl) bundle.adapt(BundleRevision.class).getWiring())
                     .isActivationTriggered())
             {
                 // Record the event type for the final event and activate.
@@ -2090,7 +2090,7 @@ public class Felix extends BundleImpl im
 
             // First get the update-URL from our header.
             String updateLocation = (String)
-                ((BundleRevisionImpl) bundle.getCurrentRevision())
+                ((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                     .getHeaders().get(Constants.BUNDLE_UPDATELOCATION);
 
             // If no update location specified, use original location.
@@ -2231,7 +2231,8 @@ public class Felix extends BundleImpl im
 
             // If the old state was active, but the new revision is a fragment,
             // then mark the persistent state to inactive.
-            if ((oldState == Bundle.ACTIVE) && Util.isFragment(bundle.getCurrentRevision()))
+            if ((oldState == Bundle.ACTIVE)
+                && Util.isFragment(bundle.adapt(BundleRevision.class)))
             {
                 bundle.setPersistentStateInactive();
                 m_logger.log(bundle, Logger.LOG_WARNING,
@@ -2324,7 +2325,7 @@ public class Felix extends BundleImpl im
 
             // As per the OSGi spec, fragment bundles can not be stopped and must
             // throw a BundleException when there is an attempt to stop one.
-            if (Util.isFragment(bundle.getCurrentRevision()))
+            if (Util.isFragment(bundle.adapt(BundleRevision.class)))
             {
                 throw new BundleException("Fragment bundles can not be stopped: " + bundle);
             }
@@ -2336,7 +2337,7 @@ public class Felix extends BundleImpl im
                     throw new IllegalStateException("Cannot stop an uninstalled bundle.");
                 case Bundle.STARTING:
                     if (bundle.isDeclaredActivationPolicyUsed()
-                        && ((BundleRevisionImpl) bundle.getCurrentRevision())
+                        && ((BundleRevisionImpl) bundle.adapt(BundleRevision.class))
                             .getDeclaredActivationPolicy() != BundleRevisionImpl.LAZY_ACTIVATION)
                     {
                         throw new BundleException(
@@ -3682,11 +3683,11 @@ public class Felix extends BundleImpl im
         }
     }
 
-    private void resolveBundle(BundleImpl bundle) throws BundleException
+    private void resolveBundle(Bundle bundle) throws BundleException
     {
         try
         {
-            m_resolver.resolve(bundle.getCurrentRevision());
+            m_resolver.resolve(bundle.adapt(BundleRevision.class));
         }
         catch (ResolveException ex)
         {
@@ -4016,7 +4017,7 @@ public class Felix extends BundleImpl im
         return true;
     }
 
-    private BundleActivator createBundleActivator(BundleImpl impl)
+    private BundleActivator createBundleActivator(Bundle impl)
         throws Exception
     {
         // CONCURRENCY NOTE:
@@ -4025,7 +4026,7 @@ public class Felix extends BundleImpl im
 
         // Get the activator class from the header map.
         BundleActivator activator = null;
-        Map headerMap = ((BundleRevisionImpl) impl.getCurrentRevision()).getHeaders();
+        Map headerMap = ((BundleRevisionImpl) impl.adapt(BundleRevision.class)).getHeaders();
         String className = (String) headerMap.get(Constants.BUNDLE_ACTIVATOR);
         // Try to instantiate activator class if present.
         if (className != null)
@@ -4035,7 +4036,7 @@ public class Felix extends BundleImpl im
             try
             {
                 clazz = ((BundleWiringImpl)
-                    impl.getCurrentRevision().getWiring()).getClassByDelegation(className);
+                    impl.adapt(BundleRevision.class).getWiring()).getClassByDelegation(className);
             }
             catch (ClassNotFoundException ex)
             {

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java Fri Jun 10 17:09:07 2011
@@ -81,7 +81,7 @@ class PackageAdminImpl implements Packag
             String sym = bundles[i].getSymbolicName();
             if ((sym != null) && sym.equals(symbolicName))
             {
-                Version v = ((BundleImpl) bundles[i]).getCurrentRevision().getVersion();
+                Version v = bundles[i].adapt(BundleRevision.class).getVersion();
                 if ((vr == null) || vr.isInRange(v))
                 {
                     list.add(bundles[i]);
@@ -96,8 +96,8 @@ class PackageAdminImpl implements Packag
         Arrays.sort(bundles,new Comparator() {
             public int compare(Object o1, Object o2)
             {
-                Version v1 = ((BundleImpl) o1).getCurrentRevision().getVersion();
-                Version v2 = ((BundleImpl) o2).getCurrentRevision().getVersion();
+                Version v1 = ((Bundle) o1).adapt(BundleRevision.class).getVersion();
+                Version v2 = ((Bundle) o2).adapt(BundleRevision.class).getVersion();
                 // Compare in reverse order to get descending sort.
                 return v2.compareTo(v1);
             }
@@ -108,7 +108,7 @@ class PackageAdminImpl implements Packag
     public int getBundleType(Bundle bundle)
     {
         Map headerMap = ((BundleRevisionImpl)
-            ((BundleImpl) bundle).getCurrentRevision()).getHeaders();
+            bundle.adapt(BundleRevision.class)).getHeaders();
         if (headerMap.containsKey(Constants.FRAGMENT_HOST))
         {
             return PackageAdmin.BUNDLE_TYPE_FRAGMENT;

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java Fri Jun 10 17:09:07 2011
@@ -485,11 +485,11 @@ class ServiceRegistrationImpl implements
             // Get the package.
             String pkgName =
                 Util.getClassPackage(className);
-            BundleRevision requesterRevision = ((BundleImpl) requester).getCurrentRevision();
+            BundleRevision requesterRevision = requester.adapt(BundleRevision.class);
             // Get package wiring from service requester.
             BundleWire requesterWire = Util.getWire(requesterRevision, pkgName);
             // Get package wiring from service provider.
-            BundleRevision providerRevision = ((BundleImpl) m_bundle).getCurrentRevision();
+            BundleRevision providerRevision = m_bundle.adapt(BundleRevision.class);
             BundleWire providerWire = Util.getWire(providerRevision, pkgName);
 
             // There are four situations that may occur here:

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java?rev=1134391&r1=1134390&r2=1134391&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java Fri Jun 10 17:09:07 2011
@@ -468,7 +468,7 @@ class StatefulResolver
             {
                 // There is nothing we can do.
             }
-            if (bundle.getCurrentRevision() == revision)
+            if (bundle.adapt(BundleRevision.class) == revision)
             {
                 if (bundle.getState() != Bundle.INSTALLED)
                 {