Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 24871 invoked from network); 5 Jun 2007 15:20:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jun 2007 15:20:21 -0000 Received: (qmail 77302 invoked by uid 500); 5 Jun 2007 15:20:20 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 77278 invoked by uid 500); 5 Jun 2007 15:20:20 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 77269 invoked by uid 99); 5 Jun 2007 15:20:20 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jun 2007 08:20:20 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Jun 2007 08:20:15 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id BEA171A981A; Tue, 5 Jun 2007 08:19:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r544515 - in /felix/trunk/framework/src/main/java/org/apache/felix: framework/ framework/searchpolicy/ moduleloader/ Date: Tue, 05 Jun 2007 15:19:53 -0000 To: commits@felix.apache.org From: rickhall@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070605151954.BEA171A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rickhall Date: Tue Jun 5 08:19:52 2007 New Revision: 544515 URL: http://svn.apache.org/viewvc?view=rev&rev=544515 Log: Modified bundle URL resource handling to remove the bundle class path index from the resource path to the URL port number. This is a quick and dirty hack that needs to be revisited, perhaps after spec clarification. Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/SystemBundle.java felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/URLPolicyImpl.java felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/SystemBundle.java URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/SystemBundle.java?view=diff&rev=544515&r1=544514&r2=544515 ============================================================================== --- felix/trunk/framework/src/main/java/org/apache/felix/framework/SystemBundle.java (original) +++ felix/trunk/framework/src/main/java/org/apache/felix/framework/SystemBundle.java Tue Jun 5 08:19:52 2007 @@ -492,12 +492,12 @@ return null; } - public boolean hasInputStream(String urlPath) throws IOException + public boolean hasInputStream(int index, String urlPath) throws IOException { return (getClass().getClassLoader().getResource(urlPath) != null); } - public InputStream getInputStream(String urlPath) throws IOException + public InputStream getInputStream(int index, String urlPath) throws IOException { return getClass().getClassLoader().getResourceAsStream(urlPath); } Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java?view=diff&rev=544515&r1=544514&r2=544515 ============================================================================== --- felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java (original) +++ felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java Tue Jun 5 08:19:52 2007 @@ -55,7 +55,7 @@ } // Verify that the resource pointed to be the URL exists. // The URL is constructed like this: - // bundle:/// + // bundle://:/ // Where = . long bundleId = Util.getBundleIdFromModuleId(url.getHost()); BundleImpl bundle = (BundleImpl) m_framework.getBundle(bundleId); @@ -66,7 +66,7 @@ int revision = Util.getModuleRevisionFromModuleId(url.getHost()); IModule[] modules = bundle.getInfo().getModules(); if ((modules == null) || (revision < 0) || (revision >= modules.length) || - !modules[revision].getContentLoader().hasInputStream(url.getPath())) + !modules[revision].getContentLoader().hasInputStream(url.getPort(), url.getPath())) { throw new IOException("Resource does not exist: " + url); } @@ -77,7 +77,7 @@ if (!connected) { // The URL is constructed like this: - // bundle:/// + // bundle://:/ // Where = . long bundleId = Util.getBundleIdFromModuleId(url.getHost()); BundleImpl bundle = (BundleImpl) m_framework.getBundle(bundleId); @@ -91,7 +91,8 @@ { throw new IOException("Resource does not exist: " + url); } - m_is = bundle.getInfo().getModules()[revision].getContentLoader().getInputStream(url.getPath()); + m_is = bundle.getInfo().getModules()[revision] + .getContentLoader().getInputStream(url.getPort(), url.getPath()); m_contentLength = (m_is == null) ? 0 : m_is.available(); m_contentTime = 0L; m_contentType = URLConnection.guessContentTypeFromName(url.getFile()); Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java?view=diff&rev=544515&r1=544514&r2=544515 ============================================================================== --- felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java (original) +++ felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentLoaderImpl.java Tue Jun 5 08:19:52 2007 @@ -143,7 +143,7 @@ { if (getClassPath()[i].hasEntry(name)) { - url = getURLPolicy().createURL((i + 1) + "/" + name); + url = getURLPolicy().createURL(i + 1, name); } } @@ -169,7 +169,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(getURLPolicy().createURL(i + 1, name)); } } @@ -186,7 +186,7 @@ // the root of the bundle according to the spec. if (name.equals("/")) { - url = getURLPolicy().createURL("0/"); + url = getURLPolicy().createURL(0, "/"); } if (url == null) @@ -203,54 +203,38 @@ // 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 = getURLPolicy().createURL(0, name); } } return url; } - public boolean hasInputStream(String urlPath) + public boolean hasInputStream(int index, String urlPath) { if (urlPath.startsWith("/")) { urlPath = urlPath.substring(1); } - // The urlPath is the path portion of a resource URL - // that is contructed above in getResouce() like this: - // / - // where == 0 is the module content - // and > 0 is the index into the class - // path - 1. - int idx = Integer.parseInt(urlPath.substring(0, urlPath.indexOf('/'))); - urlPath = urlPath.substring(urlPath.indexOf('/') + 1); - if (idx == 0) + if (index == 0) { return m_content.hasEntry(urlPath); } - return m_contentPath[idx - 1].hasEntry(urlPath); + return m_contentPath[index - 1].hasEntry(urlPath); } - public InputStream getInputStream(String urlPath) + public InputStream getInputStream(int index, String urlPath) throws IOException { if (urlPath.startsWith("/")) { urlPath = urlPath.substring(1); } - // The urlPath is the path portion of a resource URL - // that is contructed above in getResouce() like this: - // / - // where == 0 is the module content - // and > 0 is the index into the class - // path - 1. - int idx = Integer.parseInt(urlPath.substring(0, urlPath.indexOf('/'))); - urlPath = urlPath.substring(urlPath.indexOf('/') + 1); - if (idx == 0) + if (index == 0) { return m_content.getEntryAsStream(urlPath); } - return m_contentPath[idx - 1].getEntryAsStream(urlPath); + return m_contentPath[index - 1].getEntryAsStream(urlPath); } public String toString() Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/URLPolicyImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/URLPolicyImpl.java?view=diff&rev=544515&r1=544514&r2=544515 ============================================================================== --- felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/URLPolicyImpl.java (original) +++ felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/URLPolicyImpl.java Tue Jun 5 08:19:52 2007 @@ -41,7 +41,7 @@ m_module = module; } - public URL createURL(String path) + public 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 @@ -55,7 +55,7 @@ { return m_secureAction.createURL( FelixConstants.BUNDLE_URL_PROTOCOL, - m_module.getId(), -1, path, m_streamHandler); + m_module.getId(), port, path, m_streamHandler); } catch (MalformedURLException ex) { Modified: felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java?view=diff&rev=544515&r1=544514&r2=544515 ============================================================================== --- felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java (original) +++ felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IContentLoader.java Tue Jun 5 08:19:52 2007 @@ -41,8 +41,16 @@ public Enumeration getResources(String name); public URL getResourceFromContent(String name); - public boolean hasInputStream(String urlPath) + // TODO: ML - For expediency, the index argument was added to these methods + // but it is not clear that this makes sense in the long run. This needs to + // be readdressed in the future, perhaps by the spec to clearly indicate + // how resources on the bundle class path are searched, which is why we + // need the index number in the first place -- to differentiate among + // resources with the same name on the bundle class path. This was previously + // handled as part of the resource path, but that approach is not spec + // compliant. + public boolean hasInputStream(int index, String urlPath) throws IOException; - public InputStream getInputStream(String urlPath) + public InputStream getInputStream(int index, String urlPath) throws IOException; } Modified: felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java?view=diff&rev=544515&r1=544514&r2=544515 ============================================================================== --- felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java (original) +++ felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/IURLPolicy.java Tue Jun 5 08:19:52 2007 @@ -22,5 +22,13 @@ public interface IURLPolicy { - public URL createURL(String path); + // TODO: ML - For expediency, the port argument was added to this method + // but it is not clear that it makes sense in the long run. This needs to + // be readdressed in the future, perhaps by the spec to clearly indicate + // how resources on the bundle class path are searched, which is why we + // need the port number in the first place -- to differentiate among + // resources with the same name on the bundle class path. This was previously + // handled as part of the resource path, but that approach is not spec + // compliant. + public URL createURL(int port, String path); }