geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1297366 - in /geronimo/server/branches/3.0-beta: framework/modules/geronimo-kernel/ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel...
Date Tue, 06 Mar 2012 07:20:28 GMT
Author: gawor
Date: Tue Mar  6 07:20:28 2012
New Revision: 1297366

URL: http://svn.apache.org/viewvc?rev=1297366&view=rev
Log:
GERONIMO-6295: Jasper does not deal well with bundle:// urls. Convert bundle:// url to jar://
urls when possible

Modified:
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/pom.xml
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java
    geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundleContext.java
    geronimo/server/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java
    geronimo/server/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/pom.xml?rev=1297366&r1=1297365&r2=1297366&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/pom.xml (original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/pom.xml Tue Mar  6
07:20:28 2012
@@ -98,6 +98,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>
@@ -155,6 +161,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/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java?rev=1297366&r1=1297365&r2=1297366&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/FrameworkUtils.java
Tue Mar  6 07:20:28 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/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java?rev=1297366&r1=1297365&r2=1297366&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundle.java
Tue Mar  6 07:20:28 2012
@@ -215,4 +215,16 @@ public class MockBundle implements Bundl
     public void setBundleContext(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
+
+    public <A> A adapt(Class<A> arg0) {
+        return null;
+    }
+
+    public File getDataFile(String arg0) {
+        return null;
+    }
+
+    public int compareTo(Bundle o) {
+        return 0;
+    }
 }

Modified: geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundleContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundleContext.java?rev=1297366&r1=1297365&r2=1297366&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundleContext.java
(original)
+++ geronimo/server/branches/3.0-beta/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/osgi/MockBundleContext.java
Tue Mar  6 07:20:28 2012
@@ -22,6 +22,7 @@ package org.apache.geronimo.kernel.osgi;
 
 import java.io.InputStream;
 import java.io.File;
+import java.util.Collection;
 import java.util.Dictionary;
 import java.util.Map;
 import java.util.HashMap;
@@ -155,11 +156,11 @@ public class MockBundleContext implement
     public void removeFrameworkListener(FrameworkListener frameworkListener) {
     }
 
-    public ServiceRegistration registerService(String[] strings, Object o, Dictionary dictionary)
{
+    public ServiceRegistration registerService(String[] strings, Object o, Dictionary<String,
?> dictionary) {
         return null;
     }
 
-    public ServiceRegistration registerService(String s, Object o, Dictionary dictionary)
{
+    public ServiceRegistration registerService(String s, Object o, Dictionary<String,
?> dictionary) {
         ServiceReference sr = new MockServiceReference(o);
         serviceReferences.put(s, sr);
         return new MockServiceRegistration(s, sr);
@@ -177,11 +178,11 @@ public class MockBundleContext implement
         return serviceReferences.get(s);
     }
 
-    public Object getService(ServiceReference serviceReference) {
-        return ((MockServiceReference)serviceReference).service;
+    public <S>S getService(ServiceReference<S> serviceReference) {
+        return (S) ((MockServiceReference)serviceReference).service;
     }
 
-    public boolean ungetService(ServiceReference serviceReference) {
+    public boolean ungetService(ServiceReference<?> serviceReference) {
         return false;
     }
 
@@ -285,4 +286,21 @@ public class MockBundleContext implement
         }
     }
 
+    @Override
+    public Bundle getBundle(String arg0) {
+        return null;
+    }
+
+    public <S> ServiceReference<S> getServiceReference(Class<S> arg0) {
+        return null;
+    }
+
+    public <S> Collection<ServiceReference<S>> getServiceReferences(Class<S>
arg0, String arg1) throws InvalidSyntaxException {
+        return null;
+    }
+
+    public <S> ServiceRegistration<S> registerService(Class<S> arg0, S
arg1, Dictionary<String, ?> arg2) {
+        return null;
+    }
+
 }

Modified: geronimo/server/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java?rev=1297366&r1=1297365&r2=1297366&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java
(original)
+++ geronimo/server/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java
Tue Mar  6 07:20:28 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/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java?rev=1297366&r1=1297365&r2=1297366&view=diff
==============================================================================
--- geronimo/server/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java
(original)
+++ geronimo/server/branches/3.0-beta/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/internal/TldRegistryImpl.java
Tue Mar  6 07:20:28 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.xbean.osgi.bundle.util.BundleResourceFinder;
 import org.apache.xbean.osgi.bundle.util.BundleUtils;
@@ -149,7 +150,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;
         }
 



Mime
View raw message