Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 11ED29DE2 for ; Tue, 6 Mar 2012 08:00:11 +0000 (UTC) Received: (qmail 485 invoked by uid 500); 6 Mar 2012 08:00:10 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 430 invoked by uid 500); 6 Mar 2012 08:00:10 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 414 invoked by uid 99); 6 Mar 2012 08:00:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2012 08:00:09 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2012 08:00:08 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 53D0723889E1; Tue, 6 Mar 2012 07:59:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1297372 - in /geronimo/server/trunk: framework/modules/geronimo-kernel/ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/ plugins/jaspe... Date: Tue, 06 Mar 2012 07:59:48 -0000 To: scm@geronimo.apache.org From: gawor@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120306075948.53D0723889E1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gawor Date: Tue Mar 6 07:59:47 2012 New Revision: 1297372 URL: http://svn.apache.org/viewvc?rev=1297372&view=rev Log: GERONIMO-6295: Jasper does not deal well with bundle:// urls. Convert bundle:// url to jar:// urls when possible Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml?rev=1297372&r1=1297371&r2=1297372&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml (original) +++ geronimo/server/trunk/framework/modules/geronimo-kernel/pom.xml Tue Mar 6 07:59:47 2012 @@ -112,6 +112,12 @@ + org.eclipse.osgi + org.eclipse.osgi + provided + + + junit junit test @@ -173,6 +179,19 @@ + + + org.apache.felix + maven-bundle-plugin + + + + org.eclipse.*;resolution:=optional, + * + + + + Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java?rev=1297372&r1=1297371&r2=1297372&view=diff ============================================================================== --- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java (original) +++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java Tue Mar 6 07:59:47 2012 @@ -19,8 +19,14 @@ package org.apache.geronimo.kernel.osgi; +import java.io.IOException; +import java.net.URL; + +import org.eclipse.osgi.service.urlconversion.URLConverter; import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; /** * @version $Rev$ $Date$ @@ -31,6 +37,7 @@ public class FrameworkUtils { private static final boolean useURLClassLoader = initUseURLClassLoader(); private static final boolean isEquinox = initIsEquinox(); + private static final Object urlConverter = initUrlConverter(); private static boolean initUseURLClassLoader() { String property = System.getProperty(USE_URL_CLASSLOADER, "false"); @@ -48,6 +55,18 @@ public class FrameworkUtils { return false; } + private static Object initUrlConverter() { + if (isEquinox) { + Bundle bundle = FrameworkUtil.getBundle(FrameworkUtils.class); + BundleContext context = bundle.getBundleContext(); + ServiceReference reference = context.getServiceReference(URLConverter.class.getName()); + if (reference != null) { + return context.getService(reference); + } + } + return null; + } + public static boolean isEquinox() { return isEquinox; } @@ -55,4 +74,15 @@ public class FrameworkUtils { public static boolean useURLClassLoader() { return useURLClassLoader; } + + public static URL convertURL(URL bundleURL) { + if (urlConverter != null && bundleURL != null) { + try { + return ((URLConverter) urlConverter).resolve(bundleURL); + } catch (IOException e) { + // ignore + } + } + return bundleURL; + } } Modified: geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java?rev=1297372&r1=1297371&r2=1297372&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java (original) +++ geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java Tue Mar 6 07:59:47 2012 @@ -30,18 +30,25 @@ public interface TldProvider { private URL url; private Bundle bundle; private URL jarUrl; + private String name; public TldEntry(Bundle bundle, URL url) { - this.bundle = bundle; - this.url = url; + this(bundle, url, null); } public TldEntry(Bundle bundle, URL url, URL jarUrl) { this.bundle = bundle; this.url = url; this.jarUrl = jarUrl; + + String path = url.getPath(); + if (path.startsWith("/")) { + name = path.substring(1); + } else { + name = path; + } } - + public URL getURL() { return url; } @@ -55,7 +62,7 @@ public interface TldProvider { } public String getName() { - return url.getPath(); + return name; } } Modified: geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java?rev=1297372&r1=1297371&r2=1297372&view=diff ============================================================================== --- geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java (original) +++ geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java Tue Mar 6 07:59:47 2012 @@ -30,6 +30,7 @@ import java.util.zip.ZipEntry; import org.apache.geronimo.jasper.TldProvider; import org.apache.geronimo.jasper.TldRegistry; +import org.apache.geronimo.kernel.osgi.FrameworkUtils; import org.apache.geronimo.system.configuration.DependencyManager; import org.apache.geronimo.system.configuration.OsgiMetaDataProvider; import org.apache.xbean.osgi.bundle.util.BundleResourceFinder; @@ -150,7 +151,20 @@ public class TldRegistryImpl implements public boolean foundInDirectory(Bundle bundle, String basePath, URL url) throws Exception { LOGGER.debug("Found {} TLD in bundle {}", url, bundle); - tlds.add(new TldProvider.TldEntry(bundle, url)); + URL jarURL = null; + /* + * Try to convert to jar: url if possible. Makes life easier for Japser. + * See GERONIMO-6295. + */ + URL convertedURL = FrameworkUtils.convertURL(url); + if ("jar".equals(convertedURL.getProtocol())) { + String urlString = convertedURL.toExternalForm(); + int pos = urlString.indexOf("!/"); + if (pos != -1) { + jarURL = new URL(urlString.substring(4 /* jar: */, pos)); + } + } + tlds.add(new TldProvider.TldEntry(bundle, url, jarURL)); return true; }