You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2012/03/06 08:59:48 UTC
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...
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 @@
</dependency>
<dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
@@ -173,6 +179,19 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.eclipse.*;resolution:=optional,
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
</plugins>
</build>
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;
}