felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1099489 [1/5] - in /felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework: ./ capabilityset/ resolver/ util/ util/manifestparser/ wiring/
Date Wed, 04 May 2011 15:36:51 GMT
Author: rickhall
Date: Wed May  4 15:36:50 2011
New Revision: 1099489

URL: http://svn.apache.org/viewvc?rev=1099489&view=rev
Log:
Reapply patch to replace ModuleImpl with BundleRevisionImpl.

Added:
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostBundleRevision.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/ResolverWire.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java
  (with props)
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/wiring/FelixBundleWire.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/wiring/FelixBundleWireImpl.java
  (with props)
Removed:
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ModuleImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostModule.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Module.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Wire.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java
Modified:
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExtensionManager.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/Felix.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/FilterImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ResolverStateImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ServiceRegistry.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/URLHandlersBundleStreamHandler.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/CandidateComparator.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Candidates.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/ResolveException.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/Resolver.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/util/Util.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java
    felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleImpl.java
(original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleImpl.java
Wed May  4 15:36:50 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.framework;
 
+import com.sun.xml.internal.ws.api.server.Module;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -25,12 +26,12 @@ import java.security.ProtectionDomain;
 import java.util.*;
 
 import org.apache.felix.framework.cache.BundleArchive;
-import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.ext.SecurityProvider;
-import org.apache.felix.framework.resolver.Wire;
 import org.apache.felix.framework.util.StringMap;
 import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.wiring.FelixBundleWire;
 import org.osgi.framework.*;
+import org.osgi.framework.wiring.BundleRevision;
 
 class BundleImpl implements Bundle
 {
@@ -38,7 +39,7 @@ class BundleImpl implements Bundle
     private final Felix __m_felix;
 
     private final BundleArchive m_archive;
-    private final List<Module> m_modules = new ArrayList<Module>(0);
+    private final List<BundleRevision> m_revisions = new ArrayList<BundleRevision>(0);
     private volatile int m_state;
     private boolean m_useDeclaredActivationPolicy;
     private BundleActivator m_activator = null;
@@ -78,8 +79,8 @@ class BundleImpl implements Bundle
         m_activator = null;
         m_context = null;
 
-        Module module = createModule();
-        addModule(module);
+        BundleRevision revision = createRevision();
+        addRevision(revision);
     }
 
     // This method exists because the system bundle extends BundleImpl
@@ -98,7 +99,7 @@ class BundleImpl implements Bundle
 
     synchronized void close()
     {
-        closeModules();
+        closeRevisions();
         try
         {
             m_archive.close();
@@ -116,38 +117,38 @@ class BundleImpl implements Bundle
     {
         // Mark the bundle as stale, since it is being deleted.
         m_stale = true;
-        // Close all modules.
-        closeModules();
+        // Close all revisions.
+        closeRevisions();
         // Delete bundle archive, which will close revisions.
         m_archive.closeAndDelete();
     }
 
-    private void closeModules()
+    private void closeRevisions()
     {
-        // Remove the bundle's associated modules from the resolver state
+        // Remove the bundle's associated revisions from the resolver state
         // and close them.
-        for (Module m : m_modules)
+        for (BundleRevision br : m_revisions)
         {
-            // Remove the module from the resolver state.
-            getFramework().getResolver().removeModule(m);
+            // Remove the revision from the resolver state.
+            getFramework().getResolver().removeRevision(br);
 
-            // Set fragments to null, which will remove the module from all
-            // of its dependent fragment modules.
+            // Set fragments to null, which will remove the revision from all
+            // of its dependent fragment revisions.
             try
             {
-                ((ModuleImpl) m).attachFragments(null);
+                ((BundleRevisionImpl) br).attachFragments(null);
             }
             catch (Exception ex)
             {
                 getFramework().getLogger().log(
-                    m.getBundle(), Logger.LOG_ERROR, "Error detaching fragments.", ex);
+                    br.getBundle(), Logger.LOG_ERROR, "Error detaching fragments.", ex);
             }
-            // Set wires to null, which will remove the module from all
-            // of its dependent modules.
-            ((ModuleImpl) m).setWires(null);
+            // Set wires to null, which will remove the revision from all
+            // of its dependent revisions.
+            ((BundleRevisionImpl) br).setWires(null);
 
-            // Close the module's content.
-            ((ModuleImpl) m).close();
+            // Close the revision's content.
+            ((BundleRevisionImpl) br).close();
         }
     }
 
@@ -160,17 +161,17 @@ class BundleImpl implements Bundle
         }
         else
         {
-            // Dispose of the current modules.
-            closeModules();
+            // Dispose of the current revisions.
+            closeRevisions();
 
             // Now we will purge all old revisions, only keeping the newest one.
             m_archive.purge();
 
             // Lastly, we want to reset our bundle be reinitializing our state
-            // and recreating a module for the newest revision.
-            m_modules.clear();
-            final Module module = createModule();
-            addModule(module);
+            // and recreating a revision object for the newest revision.
+            m_revisions.clear();
+            final BundleRevision br = createRevision();
+            addRevision(br);
             m_state = Bundle.INSTALLED;
             m_stale = false;
             m_cachedHeaders.clear();
@@ -323,7 +324,8 @@ class BundleImpl implements Bundle
         // Spec says empty local returns raw headers.
         if (locale.length() == 0)
         {
-            result = new StringMap(getCurrentModule().getHeaders(), false);
+            result = new StringMap(
+                ((BundleRevisionImpl) getCurrentRevision()).getHeaders(), false);
         }
 
         // If we have no result, try to get it from the cached headers.
@@ -359,7 +361,8 @@ class BundleImpl implements Bundle
         if (result == null)
         {
             // Get a modifiable copy of the raw headers.
-            Map headers = new StringMap(getCurrentModule().getHeaders(), false);
+            Map headers = new StringMap(
+                ((BundleRevisionImpl) getCurrentRevision()).getHeaders(), false);
             // Assume for now that this will be the result.
             result = headers;
 
@@ -388,23 +391,22 @@ class BundleImpl implements Bundle
                     basename = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME;
                 }
 
-                // Create ordered list of modules to search for localization
+                // Create ordered list of revisions to search for localization
                 // property resources.
-                List moduleList = createLocalizationModuleList(
-                    (ModuleImpl) getCurrentModule());
+                List<BundleRevision> revisionList = createLocalizationRevisionList(
+                    (BundleRevisionImpl) getCurrentRevision());
 
                 // Create ordered list of files to load properties from
-                List resourceList = createLocalizationResourceList(basename, locale);
+                List<String> resourceList = createLocalizationResourceList(basename,
locale);
 
                 // Create a merged props file with all available props for this locale
                 boolean found = false;
                 Properties mergedProperties = new Properties();
-                for (int modIdx = 0; modIdx < moduleList.size(); modIdx++)
+                for (BundleRevision br : revisionList)
                 {
-                    for (Iterator it = resourceList.iterator(); it.hasNext(); )
+                    for (String res : resourceList)
                     {
-                        URL temp = ((Module) moduleList.get(modIdx)).getEntry(
-                            it.next() + ".properties");
+                        URL temp = ((BundleRevisionImpl) br).getEntry(res + ".properties");
                         if (temp != null)
                         {
                             found = true;
@@ -466,36 +468,38 @@ class BundleImpl implements Bundle
         }
     }
 
-    private static List createLocalizationModuleList(ModuleImpl module)
+    private static List<BundleRevision> createLocalizationRevisionList(
+        BundleRevisionImpl bri)
     {
-        // If the module is a fragment, then we actually need
+        // If the revision is a fragment, then we actually need
         // to search its host and associated fragments for its
         // localization information. So, check to see if there
         // are any hosts and then use the one with the highest
         // version instead of the fragment itself. If there are
-        // no hosts, but the module is a fragment, then just
-        // search the module itself.
-        if (Util.isFragment(module))
+        // no hosts, but the revision is a fragment, then just
+        // search the revision itself.
+        if (Util.isFragment(bri))
         {
-            List<Wire> hostWires = module.getWires();
+            List<FelixBundleWire> hostWires = bri.getWires();
             if ((hostWires != null) && (hostWires.size() > 0))
             {
-                module = (ModuleImpl) hostWires.get(0).getExporter();
+                bri = (BundleRevisionImpl) hostWires.get(0).getProviderWiring().getRevision();
                 for (int hostIdx = 1; hostIdx < hostWires.size(); hostIdx++)
                 {
-                    if (module.getVersion().compareTo(
-                        hostWires.get(hostIdx).getExporter().getVersion()) < 0)
+                    if (bri.getVersion().compareTo(
+                        hostWires.get(hostIdx).getProviderWiring().getRevision().getVersion())
< 0)
                     {
-                        module = (ModuleImpl) hostWires.get(hostIdx).getExporter();
+                        bri = (BundleRevisionImpl)
+                            hostWires.get(hostIdx).getProviderWiring().getRevision();
                     }
                 }
             }
         }
 
-        // Create a list of the module and any attached fragments.
-        List result = new ArrayList();
-        result.add(module);
-        List<Module> fragments = module.getFragments();
+        // Create a list of the revision and any attached fragment revisions.
+        List<BundleRevision> result = new ArrayList<BundleRevision>();
+        result.add(bri);
+        List<BundleRevision> fragments = bri.getFragments();
         if (fragments != null)
         {
             result.addAll(fragments);
@@ -503,9 +507,9 @@ class BundleImpl implements Bundle
         return result;
     }
 
-    private static List createLocalizationResourceList(String basename, String locale)
+    private static List<String> createLocalizationResourceList(String basename, String
locale)
     {
-        List result = new ArrayList(4);
+        List<String> result = new ArrayList(4);
 
         StringTokenizer tokens;
         StringBuffer tempLocale = new StringBuffer(basename);
@@ -853,9 +857,9 @@ class BundleImpl implements Bundle
 
     synchronized boolean isExtension()
     {
-        for (int i = (m_modules.size() - 1); i > -1; i--)
+        for (int i = (m_revisions.size() - 1); i > -1; i--)
         {
-            if (m_modules.get(i).isExtension())
+            if (((BundleRevisionImpl) m_revisions.get(i)).isExtension())
             {
                 return true;
             }
@@ -865,12 +869,12 @@ class BundleImpl implements Bundle
 
     public String getSymbolicName()
     {
-        return getCurrentModule().getSymbolicName();
+        return getCurrentRevision().getSymbolicName();
     }
 
     public Version getVersion()
     {
-        return getCurrentModule().getVersion();
+        return getCurrentRevision().getVersion();
     }
 
     public boolean hasPermission(Object obj)
@@ -997,7 +1001,7 @@ class BundleImpl implements Bundle
 
     public String toString()
     {
-        String sym = getCurrentModule().getSymbolicName();
+        String sym = getCurrentRevision().getSymbolicName();
         if (sym != null)
         {
             return sym + " [" + getBundleId() +"]";
@@ -1007,11 +1011,11 @@ class BundleImpl implements Bundle
 
     synchronized boolean isRemovalPending()
     {
-        return (m_state == Bundle.UNINSTALLED) || (m_modules.size() > 1)  || m_stale;
+        return (m_state == Bundle.UNINSTALLED) || (m_revisions.size() > 1)  || m_stale;
     }
 
     //
-    // Module management.
+    // Revision management.
     //
 
     /**
@@ -1026,22 +1030,22 @@ class BundleImpl implements Bundle
      * no limit on the potential number of bundle JAR file revisions.
      * @return array of modules corresponding to the bundle JAR file revisions.
     **/
-    synchronized List<Module> getModules()
+    synchronized List<BundleRevision> getRevisions()
     {
-        return m_modules;
+        return m_revisions;
     }
 
     /**
      * Determines if the specified module is associated with this bundle.
-     * @param module the module to determine if it is associate with this bundle.
+     * @param revision the module to determine if it is associate with this bundle.
      * @return <tt>true</tt> if the specified module is in the array of modules
      *         associated with this bundle, <tt>false</tt> otherwise.
     **/
-    synchronized boolean hasModule(Module module)
+    synchronized boolean hasRevision(BundleRevision revision)
     {
-        for (int i = 0; i < m_modules.size(); i++)
+        for (int i = 0; i < m_revisions.size(); i++)
         {
-            if (m_modules.get(i) == module)
+            if (m_revisions.get(i) == revision)
             {
                 return true;
             }
@@ -1054,28 +1058,29 @@ class BundleImpl implements Bundle
      * in the module array.
      * @return the newest module.
     **/
-    synchronized Module getCurrentModule()
+    synchronized BundleRevision getCurrentRevision()
     {
-        return m_modules.get(m_modules.size() - 1);
+        return m_revisions.get(m_revisions.size() - 1);
     }
 
     synchronized boolean isUsed()
     {
         boolean unresolved = true;
-        for (int i = 0; unresolved && (i < m_modules.size()); i++)
+        for (int i = 0; unresolved && (i < m_revisions.size()); i++)
         {
-            if (m_modules.get(i).isResolved())
+            if (m_revisions.get(i).getWiring() != null)
             {
                 unresolved = false;
             }
         }
         boolean used = false;
-        for (int i = 0; !unresolved && !used && (i < m_modules.size());
i++)
+        for (int i = 0; !unresolved && !used && (i < m_revisions.size());
i++)
         {
-            List<Module> dependents = ((ModuleImpl) m_modules.get(i)).getDependents();
+            List<BundleRevision> dependents =
+                ((BundleRevisionImpl) m_revisions.get(i)).getDependents();
             for (int j = 0; (dependents != null) && (j < dependents.size()) &&
!used; j++)
             {
-                if (dependents.get(j) != m_modules.get(i))
+                if (dependents.get(j) != m_revisions.get(i))
                 {
                     used = true;
                 }
@@ -1091,8 +1096,8 @@ class BundleImpl implements Bundle
         m_archive.revise(location, is);
         try
         {
-            Module module = createModule();
-            addModule(module);
+            BundleRevision revision = createRevision();
+            addRevision(revision);
         }
         catch (Exception ex)
         {
@@ -1104,27 +1109,27 @@ class BundleImpl implements Bundle
     synchronized boolean rollbackRevise() throws Exception
     {
         boolean isExtension = isExtension();
-        Module m = m_modules.remove(m_modules.size() - 1);
+        BundleRevision br = m_revisions.remove(m_revisions.size() - 1);
         if (!isExtension)
         {
-            // Since revising a module adds the module to the global
+            // Since revising a bundle adds a revision to the global
             // state, we must remove it from the global state on rollback.
-            getFramework().getResolver().removeModule(m);
+            getFramework().getResolver().removeRevision(br);
         }
         return m_archive.rollbackRevise();
     }
 
     // This method should be private, but is visible because the
-    // system bundle needs to add its module directly to the bundle,
-    // since it doesn't have an archive from which the module will
-    // be created, which is the normal case.
-    synchronized void addModule(Module module) throws Exception
-    {
-        m_modules.add(module);
-
-        // Set protection domain after adding the module to the bundle,
-        // since this requires that the bundle has a module.
-        ((ModuleImpl) module).setSecurityContext(
+    // system bundle needs to add its revision directly to the bundle,
+    // since it doesn't have an archive from which it will be created,
+    // which is the normal case.
+    synchronized void addRevision(BundleRevision revision) throws Exception
+    {
+        m_revisions.add(revision);
+
+        // Set protection domain after adding the revision to the bundle,
+        // since this requires that the bundle has a revision.
+        ((BundleRevisionImpl) revision).setSecurityContext(
             new BundleProtectionDomain(getFramework(), this));
 
         SecurityProvider sp = getFramework().getSecurityProvider();
@@ -1136,30 +1141,29 @@ class BundleImpl implements Bundle
             }
             catch (Exception ex) 
             {
-                m_modules.remove(m_modules.size() - 1);
+                m_revisions.remove(m_revisions.size() - 1);
                 throw ex;
             }
         }
 
-        // TODO: REFACTOR - consider moving ModuleImpl into the framework package
-        // so we can null module capabilities for extension bundles so we don't
-        // need this check anymore.
+        // TODO: REFACTOR - consider nulling capabilities for extension bundles
+        // so we don't need this check anymore.
         if (!isExtension())
         {
-            // Now that the module is added to the bundle, we can update
-            // the resolver's module state.
-            getFramework().getResolver().addModule(module);
+            // Now that the revision is added to the bundle, we can update
+            // the resolver's state to be aware of any new capabilities.
+            getFramework().getResolver().addRevision(revision);
         }
     }
 
-    private Module createModule() throws Exception
+    private BundleRevision createRevision() throws Exception
     {
-        // Get and parse the manifest from the most recent revision to
-        // create an associated module for it.
+        // Get and parse the manifest from the most recent revision and
+        // create an associated revision object for it.
         Map headerMap = m_archive.getCurrentRevision().getManifestHeader();
 
-        // Create the module instance.
-        ModuleImpl module = new ModuleImpl(
+        // Create the bundle revision instance.
+        BundleRevisionImpl revision = new BundleRevisionImpl(
             getFramework().getLogger(),
             getFramework().getConfig(),
             getFramework().getResolver(),
@@ -1173,11 +1177,11 @@ class BundleImpl implements Bundle
             getFramework().getBootPackageWildcards());
 
         // Verify that the bundle symbolic name + version is unique.
-        if (module.getManifestVersion().equals("2"))
+        if (revision.getManifestVersion().equals("2"))
         {
-            Version bundleVersion = module.getVersion();
+            Version bundleVersion = revision.getVersion();
             bundleVersion = (bundleVersion == null) ? Version.emptyVersion : bundleVersion;
-            String symName = module.getSymbolicName();
+            String symName = revision.getSymbolicName();
 
             Bundle[] bundles = getFramework().getBundles();
             for (int i = 0; (bundles != null) && (i < bundles.length); i++)
@@ -1186,8 +1190,8 @@ class BundleImpl implements Bundle
                 if (id != getBundleId())
                 {
                     String sym = bundles[i].getSymbolicName();
-                    Version ver = ((ModuleImpl)
-                        ((BundleImpl) bundles[i]).getCurrentModule()).getVersion();
+                    Version ver = ((BundleRevisionImpl)
+                        ((BundleImpl) bundles[i]).getCurrentRevision()).getVersion();
                     if ((symName != null) && (sym != null) && symName.equals(sym)
&& bundleVersion.equals(ver))
                     {
                         throw new BundleException(
@@ -1198,16 +1202,17 @@ class BundleImpl implements Bundle
             }
         }
 
-        return module;
+        return revision;
     }
 
     synchronized ProtectionDomain getProtectionDomain()
     {
         ProtectionDomain pd = null;
 
-        for (int i = m_modules.size() - 1; (i >= 0) && (pd == null); i--)
+        for (int i = m_revisions.size() - 1; (i >= 0) && (pd == null); i--)
         {
-            pd = (ProtectionDomain) m_modules.get(i).getSecurityContext();
+            pd = (ProtectionDomain)
+                ((BundleRevisionImpl) m_revisions.get(i)).getSecurityContext();
         }
 
         return pd;
@@ -1258,4 +1263,4 @@ class BundleImpl implements Bundle
     {
         return m_context;
     }
-}
+}
\ No newline at end of file

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
(original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
Wed May  4 15:36:50 2011
@@ -25,7 +25,7 @@ import java.security.Permission;
 import java.security.ProtectionDomain;
 import java.security.cert.Certificate;
 
-import org.apache.felix.framework.resolver.Module;
+import org.osgi.framework.wiring.BundleRevision;
 
 public class BundleProtectionDomain extends ProtectionDomain
 {
@@ -33,9 +33,9 @@ public class BundleProtectionDomain exte
     private final WeakReference m_bundle;
     private final int m_hashCode;
     private final String m_toString;
-    private final WeakReference m_module;
+    private final WeakReference m_revision;
 
-    // TODO: SECURITY - This should probably take a module, not a bundle.
+    // TODO: SECURITY - This should probably take a revision, not a bundle.
     BundleProtectionDomain(Felix felix, BundleImpl bundle)
         throws MalformedURLException
     {
@@ -50,14 +50,14 @@ public class BundleProtectionDomain exte
             null);
         m_felix = new WeakReference(felix);
         m_bundle = new WeakReference(bundle);
-        m_module = new WeakReference(bundle.getCurrentModule());
+        m_revision = new WeakReference(bundle.getCurrentRevision());
         m_hashCode = bundle.hashCode();
         m_toString = "[" + bundle + "]";
     }
 
-    Module getModule() 
+    BundleRevision getRevision() 
     {
-        return (Module) m_module.get();
+        return (BundleRevision) m_revision.get();
     }
 
     public boolean implies(Permission permission)

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
(original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
Wed May  4 15:36:50 2011
@@ -22,14 +22,14 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.*;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
-import org.apache.felix.framework.resolver.Module;
+import org.osgi.framework.wiring.BundleRevision;
 
 class EntryFilterEnumeration implements Enumeration
 {
     private final BundleImpl m_bundle;
     private final List<Enumeration> m_enumerations;
-    private final List<Module> m_modules;
-    private int m_moduleIndex = 0;
+    private final List<BundleRevision> m_revisions;
+    private int m_revisionIndex = 0;
     private final String m_path;
     private final List<String> m_filePattern;
     private final boolean m_recurse;
@@ -42,23 +42,23 @@ class EntryFilterEnumeration implements 
         String filePattern, boolean recurse, boolean isURLValues)
     {
         m_bundle = bundle;
-        Module bundleModule = m_bundle.getCurrentModule();
-        List<Module> fragmentModules = ((ModuleImpl) bundleModule).getFragments();
-        if (includeFragments && (fragmentModules != null))
+        BundleRevision br = m_bundle.getCurrentRevision();
+        List<BundleRevision> fragments = ((BundleRevisionImpl) br).getFragments();
+        if (includeFragments && (fragments != null))
         {
-            m_modules = new ArrayList(fragmentModules.size() + 1);
-            m_modules.addAll(fragmentModules);
+            m_revisions = new ArrayList(fragments.size() + 1);
+            m_revisions.addAll(fragments);
         }
         else
         {
-            m_modules = new ArrayList(1);
+            m_revisions = new ArrayList(1);
         }
-        m_modules.add(0, bundleModule);
-        m_enumerations = new ArrayList(m_modules.size());
-        for (int i = 0; i < m_modules.size(); i++)
+        m_revisions.add(0, br);
+        m_enumerations = new ArrayList(m_revisions.size());
+        for (int i = 0; i < m_revisions.size(); i++)
         {
-            m_enumerations.add(m_modules.get(i).getContent() != null ?
-                m_modules.get(i).getContent().getEntries() : null);
+            m_enumerations.add(((BundleRevisionImpl) m_revisions.get(i)).getContent() !=
null ?
+                ((BundleRevisionImpl) m_revisions.get(i)).getContent().getEntries() : null);
         }
         m_recurse = recurse;
         m_isURLValues = isURLValues;
@@ -90,12 +90,12 @@ class EntryFilterEnumeration implements 
 
     public synchronized boolean hasMoreElements()
     {
-        return (m_nextEntries.size() != 0);
+        return (!m_nextEntries.isEmpty());
     }
 
     public synchronized Object nextElement()
     {
-        if (m_nextEntries.size() == 0)
+        if (m_nextEntries.isEmpty())
         {
             throw new NoSuchElementException("No more entries.");
         }
@@ -114,19 +114,19 @@ class EntryFilterEnumeration implements 
         {
             return;
         }
-        while ((m_moduleIndex < m_enumerations.size()) && (m_nextEntries.size()
== 0))
+        while ((m_revisionIndex < m_enumerations.size()) && m_nextEntries.isEmpty())
         {
-            while (m_enumerations.get(m_moduleIndex) != null
-                && m_enumerations.get(m_moduleIndex).hasMoreElements()
-                && m_nextEntries.size() == 0)
+            while (m_enumerations.get(m_revisionIndex) != null
+                && m_enumerations.get(m_revisionIndex).hasMoreElements()
+                && m_nextEntries.isEmpty())
             {
                 // Get the current entry to determine if it should be filtered or not.
-                String entryName = (String) m_enumerations.get(m_moduleIndex).nextElement();
+                String entryName = (String) m_enumerations.get(m_revisionIndex).nextElement();
                 // Check to see if the current entry is a descendent of the specified path.
                 if (!entryName.equals(m_path) && entryName.startsWith(m_path))
                 {
                     // Cached entry URL. If we are returning URLs, we use this
-                    // cached URL to avoid doing multiple URL lookups from a module
+                    // cached URL to avoid doing multiple URL lookups from a revision
                     // when synthesizing directory URLs.
                     URL entryURL = null;
 
@@ -170,11 +170,14 @@ class EntryFilterEnumeration implements 
                                         if (m_isURLValues)
                                         {
                                             entryURL = (entryURL == null)
-                                                ? m_modules.get(m_moduleIndex).getEntry(entryName)
+                                                ? ((BundleRevisionImpl)
+                                                    m_revisions.get(m_revisionIndex))
+                                                        .getEntry(entryName)
                                                 : entryURL;
                                             try
                                             {
-                                                m_nextEntries.add(new URL(entryURL, "/" +
dir));
+                                                m_nextEntries.add(
+                                                    new URL(entryURL, "/" + dir));
                                             }
                                             catch (MalformedURLException ex)
                                             {
@@ -207,7 +210,8 @@ class EntryFilterEnumeration implements 
                             if (m_isURLValues)
                             {
                                 entryURL = (entryURL == null)
-                                    ? m_modules.get(m_moduleIndex).getEntry(entryName)
+                                    ? ((BundleRevisionImpl)
+                                        m_revisions.get(m_revisionIndex)).getEntry(entryName)
                                     : entryURL;
                                 m_nextEntries.add(entryURL);
                             }
@@ -219,9 +223,9 @@ class EntryFilterEnumeration implements 
                     }
                 }
             }
-            if (m_nextEntries.size() == 0)
+            if (m_nextEntries.isEmpty())
             {
-                m_moduleIndex++;
+                m_revisionIndex++;
             }
         }
     }

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
(original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
Wed May  4 15:36:50 2011
@@ -19,27 +19,28 @@
 package org.apache.felix.framework;
 
 import java.util.List;
-import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Version;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.service.packageadmin.ExportedPackage;
 
 class ExportedPackageImpl implements ExportedPackage
 {
     private final Felix m_felix;
     private final BundleImpl m_exportingBundle;
-    private final Module m_exportingModule;
-    private final BundleCapabilityImpl m_export;
+    private final BundleRevision m_exportingRevision;
+    private final BundleCapability m_export;
     private final String m_pkgName;
     private final Version m_version;
 
     public ExportedPackageImpl(
-        Felix felix, BundleImpl exporter, Module module, BundleCapabilityImpl export)
+        Felix felix, BundleImpl exporter, BundleRevision revision, BundleCapability export)
     {
         m_felix = felix;
         m_exportingBundle = exporter;
-        m_exportingModule = module;
+        m_exportingRevision = revision;
         m_export = export;
         m_pkgName = (String) m_export.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR);
         m_version = (!m_export.getAttributes().containsKey(BundleCapabilityImpl.VERSION_ATTR))

Modified: felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExtensionManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExtensionManager.java?rev=1099489&r1=1099488&r2=1099489&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExtensionManager.java
(original)
+++ felix/sandbox/rickhall/framework-up/src/main/java/org/apache/felix/framework/ExtensionManager.java
Wed May  4 15:36:50 2011
@@ -38,7 +38,6 @@ import java.util.NoSuchElementException;
 import java.util.Set;
 
 import org.apache.felix.framework.Felix.StatefulResolver;
-import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.framework.util.StringMap;
 import org.apache.felix.framework.util.Util;
@@ -52,6 +51,8 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRevision;
 
 /**
  * The ExtensionManager class is used in several ways.
@@ -115,8 +116,8 @@ class ExtensionManager extends URLStream
 
     private final Logger m_logger;
     private final Map m_headerMap = new StringMap(false);
-    private final Module m_systemBundleModule;
-    private List<BundleCapabilityImpl> m_capabilities = null;
+    private final BundleRevision m_systemBundleRevision;
+    private List<BundleCapability> m_capabilities = null;
     private Set m_exportNames = null;
     private Object m_securityContext = null;
     private final List m_extensions;
@@ -129,7 +130,7 @@ class ExtensionManager extends URLStream
     private ExtensionManager()
     {
         m_logger = null;
-        m_systemBundleModule = null;
+        m_systemBundleRevision = null;
         m_extensions = new ArrayList();
         m_extensionsCache = new Bundle[0];
         m_names = new HashSet();
@@ -149,7 +150,7 @@ class ExtensionManager extends URLStream
      */
     ExtensionManager(Logger logger, Felix felix)
     {
-        m_systemBundleModule = new ExtensionManagerModule(felix);
+        m_systemBundleRevision = new ExtensionManagerRevision(felix);
         m_extensions = null;
         m_extensionsCache = null;
         m_names = null;
@@ -189,13 +190,13 @@ class ExtensionManager extends URLStream
         try
         {
             ManifestParser mp = new ManifestParser(
-                m_logger, felix.getConfig(), m_systemBundleModule, m_headerMap);
-            List<BundleCapabilityImpl> caps = aliasSymbolicName(mp.getCapabilities());
+                m_logger, felix.getConfig(), m_systemBundleRevision, m_headerMap);
+            List<BundleCapability> caps = aliasSymbolicName(mp.getCapabilities());
             setCapabilities(caps);
         }
         catch (Exception ex)
         {
-            m_capabilities = new ArrayList<BundleCapabilityImpl>(0);
+            m_capabilities = new ArrayList<BundleCapability>(0);
             m_logger.log(
                 Logger.LOG_ERROR,
                 "Error parsing system bundle export statement: "
@@ -203,14 +204,14 @@ class ExtensionManager extends URLStream
         }
     }
 
-    private static List<BundleCapabilityImpl> aliasSymbolicName(List<BundleCapabilityImpl>
caps)
+    private static List<BundleCapability> aliasSymbolicName(List<BundleCapability>
caps)
     {
         if (caps == null)
         {
-            return new ArrayList<BundleCapabilityImpl>(0);
+            return new ArrayList<BundleCapability>(0);
         }
 
-        List<BundleCapabilityImpl> aliasCaps = new ArrayList<BundleCapabilityImpl>(caps);
+        List<BundleCapability> aliasCaps = new ArrayList<BundleCapability>(caps);
 
         for (int capIdx = 0; capIdx < aliasCaps.size(); capIdx++)
         {
@@ -232,7 +233,7 @@ class ExtensionManager extends URLStream
                             Constants.SYSTEM_BUNDLE_SYMBOLICNAME});
                     // Create the aliased capability to replace the old capability.
                     aliasCaps.set(capIdx, new BundleCapabilityImpl(
-                        caps.get(capIdx).getModule(),
+                        caps.get(capIdx).getRevision(),
                         caps.get(capIdx).getNamespace(),
                         caps.get(capIdx).getDirectives(),
                         aliasAttrs));
@@ -245,9 +246,9 @@ class ExtensionManager extends URLStream
         return aliasCaps;
     }
 
-    public Module getModule()
+    public BundleRevision getRevision()
     {
-        return m_systemBundleModule;
+        return m_systemBundleRevision;
     }
 
     public synchronized Object getSecurityContext()
@@ -298,7 +299,8 @@ class ExtensionManager extends URLStream
         }
 
         String directive = ManifestParser.parseExtensionBundleHeader((String)
-            bundle.getCurrentModule().getHeaders().get(Constants.FRAGMENT_HOST));
+            ((BundleRevisionImpl) bundle.getCurrentRevision())
+                .getHeaders().get(Constants.FRAGMENT_HOST));
 
         // We only support classpath extensions (not bootclasspath).
         if (!Constants.EXTENSION_FRAMEWORK.equals(directive))
@@ -311,13 +313,14 @@ class ExtensionManager extends URLStream
         try
         {
             // Merge the exported packages with the exported packages of the systembundle.
-            List<BundleCapabilityImpl> exports = null;
+            List<BundleCapability> exports = null;
             try
             {
                 exports = ManifestParser.parseExportHeader(
-                    m_logger, m_systemBundleModule,
-                    (String) bundle.getCurrentModule().getHeaders().get(Constants.EXPORT_PACKAGE),
-                    m_systemBundleModule.getSymbolicName(), m_systemBundleModule.getVersion());
+                    m_logger, m_systemBundleRevision,
+                    (String) ((BundleRevisionImpl) bundle.getCurrentRevision())
+                        .getHeaders().get(Constants.EXPORT_PACKAGE),
+                    m_systemBundleRevision.getSymbolicName(), m_systemBundleRevision.getVersion());
                 exports = aliasSymbolicName(exports);
             }
             catch (Exception ex)
@@ -326,7 +329,8 @@ class ExtensionManager extends URLStream
                     bundle,
                     Logger.LOG_ERROR,
                     "Error parsing extension bundle export statement: "
-                    + bundle.getCurrentModule().getHeaders().get(Constants.EXPORT_PACKAGE),
ex);
+                    + ((BundleRevisionImpl) bundle.getCurrentRevision())
+                        .getHeaders().get(Constants.EXPORT_PACKAGE), ex);
                 return;
             }
 
@@ -344,8 +348,8 @@ class ExtensionManager extends URLStream
                 throw new UnsupportedOperationException(
                     "Unable to add extension bundle to FrameworkClassLoader - Maybe not an
URLClassLoader?");
             }
-            List<BundleCapabilityImpl> temp =
-                new ArrayList<BundleCapabilityImpl>(m_capabilities.size() + exports.size());
+            List<BundleCapability> temp =
+                new ArrayList<BundleCapability>(m_capabilities.size() + exports.size());
             temp.addAll(m_capabilities);
             temp.addAll(exports);
             setCapabilities(temp);
@@ -368,8 +372,8 @@ class ExtensionManager extends URLStream
     void startExtensionBundle(Felix felix, BundleImpl bundle)
     {
         String activatorClass = (String)
-        bundle.getCurrentModule().getHeaders().get(
-            FelixConstants.FELIX_EXTENSION_ACTIVATOR);
+            ((BundleRevisionImpl) bundle.getCurrentRevision())
+                .getHeaders().get(FelixConstants.FELIX_EXTENSION_ACTIVATOR);
 
         if (activatorClass != null)
         {
@@ -415,7 +419,7 @@ class ExtensionManager extends URLStream
         }
     }
 
-    private void setCapabilities(List<BundleCapabilityImpl> capabilities)
+    private void setCapabilities(List<BundleCapability> capabilities)
     {
         m_capabilities = capabilities;
         m_headerMap.put(Constants.EXPORT_PACKAGE, convertCapabilitiesToHeaders(m_headerMap));
@@ -497,7 +501,8 @@ class ExtensionManager extends URLStream
         {
             try
             {
-                result = ((ModuleImpl) ((BundleImpl) extBundle).getCurrentModule()).getResourceLocal(path);
+                result = ((BundleRevisionImpl) ((BundleImpl)
+                    extBundle).getCurrentRevision()).getResourceLocal(path);
             }
             catch (Exception ex)
             {
@@ -627,10 +632,10 @@ class ExtensionManager extends URLStream
     // Utility methods.
     //
 
-    class ExtensionManagerModule extends ModuleImpl
+    class ExtensionManagerRevision extends BundleRevisionImpl
     {
         private final Version m_version;
-        ExtensionManagerModule(Felix felix)
+        ExtensionManagerRevision(Felix felix)
         {
             super(m_logger, felix.getConfig(), felix, "0",
                 felix.getBootPackages(), felix.getBootPackageWildcards());
@@ -646,7 +651,7 @@ class ExtensionManager extends URLStream
             }
         }
 
-        public List<BundleCapabilityImpl> getDeclaredCapabilities()
+        public List<BundleCapability> getDeclaredCapabilities(String namespace)
         {
             synchronized (ExtensionManager.this)
             {
@@ -654,7 +659,7 @@ class ExtensionManager extends URLStream
             }
         }
 
-        public List<BundleCapabilityImpl> getResolvedCapabilities()
+        public List<BundleCapability> getCapabilities(String namespace)
         {
             synchronized (ExtensionManager.this)
             {
@@ -784,4 +789,4 @@ class ExtensionManager extends URLStream
             return getClass().getClassLoader().getResource(urlPath);
         }
     }
-}
+}
\ No newline at end of file



Mime
View raw message