felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r744260 - in /felix/trunk/framework/src/main/java/org/apache/felix: framework/ framework/searchpolicy/ moduleloader/
Date Fri, 13 Feb 2009 22:15:39 GMT
Author: rickhall
Date: Fri Feb 13 22:15:39 2009
New Revision: 744260

URL: http://svn.apache.org/viewvc?rev=744260&view=rev
Log:
Eliminated the URL policy abstraction. (FELIX-851)

Removed:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/URLPolicyImpl.java
Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.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/searchpolicy/ModuleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java
    felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IModule.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=744260&r1=744259&r2=744260&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 Feb
13 22:15:39 2009
@@ -27,7 +27,6 @@
 import org.apache.felix.framework.cache.BundleArchive;
 import org.apache.felix.framework.ext.SecurityProvider;
 import org.apache.felix.framework.searchpolicy.ModuleImpl;
-import org.apache.felix.framework.searchpolicy.URLPolicyImpl;
 import org.apache.felix.moduleloader.IModule;
 import org.osgi.framework.*;
 
@@ -586,7 +585,8 @@
         return m_state;
     }
 
-    void setState(int i)
+    // This method should not be called directly.
+    void __setState(int i)
     {
         m_state = i;
     }
@@ -940,6 +940,7 @@
         Map headerMap = m_archive.getRevision(
             m_archive.getRevisionCount() - 1).getManifestHeader();
 
+        // Create the module instance.
         final int revision = m_archive.getRevisionCount() - 1;
         ModuleImpl module = new ModuleImpl(
             getFramework().getLogger(),
@@ -948,7 +949,8 @@
             this,
             Long.toString(getBundleId()) + "." + Integer.toString(revision),
             headerMap,
-            m_archive.getRevision(revision).getContent());
+            m_archive.getRevision(revision).getContent(),
+            getFramework().getBundleStreamHandler());
 
         // Verify that the bundle symbolic name + version is unique.
         if (module.getManifestVersion().equals("2"))
@@ -974,15 +976,6 @@
             }
         }
 
-        // Set the module's URL policy.
-// TODO: REFACTOR - Pass into constructor?
-        module.setURLPolicy(
-// TODO: REFACTOR - SUCKS NEEDING URL POLICY PER MODULE.
-            new URLPolicyImpl(
-                getFramework().getLogger(),
-                getFramework().getBundleStreamHandler(),
-                module));
-
         return module;
     }
 

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=744260&r1=744259&r2=744260&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
Feb 13 22:15:39 2009
@@ -615,7 +615,7 @@
     {
         ExtensionManagerModule(Felix felix) throws BundleException
         {
-            super(m_logger, null, null, felix, "0", null, null);
+            super(m_logger, null, null, felix, "0", null, null, null);
         }
 
         public Map getHeaders()
@@ -702,16 +702,6 @@
             return ExtensionManager.this;
         }
 
-        public synchronized void setURLPolicy(IURLPolicy urlPolicy)
-        {
-            m_urlPolicy = urlPolicy;
-        }
-
-        public synchronized IURLPolicy getURLPolicy()
-        {
-            return m_urlPolicy;
-        }
-
         public URL getEntry(String name)
         {
             // There is no content for the system bundle, so return null.

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=744260&r1=744259&r2=744260&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 Feb 13 22:15:39
2009
@@ -4104,7 +4104,7 @@
     {
         synchronized (m_bundleLock)
         {
-            bundle.setState(state);
+            bundle.__setState(state);
             m_bundleLock.notifyAll();
         }
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java?rev=744260&r1=744259&r2=744260&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ModuleImpl.java
Fri Feb 13 22:15:39 2009
@@ -24,7 +24,9 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.URLStreamHandler;
 import java.security.ProtectionDomain;
 import java.security.SecureClassLoader;
 import java.util.ArrayList;
@@ -62,6 +64,7 @@
     private final String m_id;
     private final IContent m_content;
     private final Map m_headerMap;
+    private final URLStreamHandler m_streamHandler;
 
     private final String m_manifestVersion;
     private final Version m_version;
@@ -82,7 +85,6 @@
 
     private IContent[] m_contentPath;
     private IContent[] m_fragmentContents = null;
-    private IURLPolicy m_urlPolicy = null;
     private ModuleClassLoader m_classLoader;
     private ProtectionDomain m_protectionDomain = null;
     private static SecureAction m_secureAction = new SecureAction();
@@ -99,7 +101,8 @@
 
     public ModuleImpl(
         Logger logger, Map configMap, FelixResolver resolver,
-        Bundle bundle, String id, Map headerMap, IContent content)
+        Bundle bundle, String id, Map headerMap, IContent content,
+        URLStreamHandler streamHandler)
         throws BundleException
     {
         m_logger = logger;
@@ -109,6 +112,7 @@
         m_id = id;
         m_headerMap = headerMap;
         m_content = content;
+        m_streamHandler = streamHandler;
 
         // We need to special case the system bundle module, which does not
         // have a content.
@@ -600,7 +604,7 @@
         if (name.equals("/"))
         {
             // Just pick a class path index since it doesn't really matter.
-            url = getURLPolicy().createURL(1, name);
+            url = createURL(1, name);
         }
         else if (name.startsWith("/"))
         {
@@ -615,7 +619,7 @@
         {
             if (contentPath[i].hasEntry(name))
             {
-                url = getURLPolicy().createURL(i + 1, name);
+                url = createURL(i + 1, name);
             }
         }
 
@@ -803,7 +807,7 @@
         {
             for (int i = 0; i < contentPath.length; i++)
             {
-                v.addElement(getURLPolicy().createURL(i + 1, name));
+                v.addElement(createURL(i + 1, name));
             }
         }
         else
@@ -823,7 +827,7 @@
                     // that we can differentiate between module content URLs
                     // (where the path will start with 0) and module class
                     // path URLs.
-                    v.addElement(getURLPolicy().createURL(i + 1, name));
+                    v.addElement(createURL(i + 1, name));
                 }
             }
         }
@@ -841,7 +845,7 @@
         // the root of the bundle according to the spec.
         if (name.equals("/"))
         {
-            url = getURLPolicy().createURL(0, "/");
+            url = createURL(0, "/");
         }
 
         if (url == null)
@@ -858,7 +862,7 @@
                 // Module content URLs start with 0, whereas module
                 // class path URLs start with the index into the class
                 // path + 1.
-                url = getURLPolicy().createURL(0, name);
+                url = createURL(0, name);
             }
         }
 
@@ -892,6 +896,32 @@
         return getContentPath()[index - 1].getEntryAsStream(urlPath);
     }
 
+    private URL createURL(int port, String path)
+    {
+         // Add a slash if there is one already, otherwise
+         // the is no slash separating the host from the file
+         // in the resulting URL.
+         if (!path.startsWith("/"))
+         {
+             path = "/" + path;
+         }
+
+         try
+         {
+             return m_secureAction.createURL(
+                 FelixConstants.BUNDLE_URL_PROTOCOL,
+                 m_id, port, path, m_streamHandler);
+         }
+         catch (MalformedURLException ex)
+         {
+             m_logger.log(
+                 Logger.LOG_ERROR,
+                 "Unable to create resource URL.",
+                 ex);
+         }
+         return null;
+    }
+
     //
     // Fragment and dependency management methods.
     //
@@ -1086,16 +1116,6 @@
         m_classLoader = null;
     }
 
-    public synchronized void setURLPolicy(IURLPolicy urlPolicy)
-    {
-        m_urlPolicy = urlPolicy;
-    }
-
-    public synchronized IURLPolicy getURLPolicy()
-    {
-        return m_urlPolicy;
-    }
-
     public synchronized void setSecurityContext(Object securityContext)
     {
         m_protectionDomain = (ProtectionDomain) securityContext;

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java?rev=744260&r1=744259&r2=744260&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/Resolver.java
Fri Feb 13 22:15:39 2009
@@ -51,8 +51,6 @@
 
     // Returns a map of resolved bundles where the key is the module
     // and the value is an array of wires.
-    // TODO: RESOLVER - The caller must ensure this is not called currently;
-    //       this may not be important if no state is shared.
     public Map resolve(ResolverState state, IModule rootModule) throws ResolveException
     {
         // If the module is already resolved, then we can just return.

Modified: felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IModule.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IModule.java?rev=744260&r1=744259&r2=744260&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IModule.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IModule.java Fri Feb
13 22:15:39 2009
@@ -28,8 +28,6 @@
 
 public interface IModule
 {
-    void setURLPolicy(IURLPolicy urlPolicy);
-    IURLPolicy getURLPolicy();
     void setSecurityContext(Object securityContext);
     Object getSecurityContext();
 



Mime
View raw message