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 2010/01/27 21:09:50 UTC

svn commit: r903814 - in /geronimo/server/trunk: framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ plugins/j2ee/geronimo-j2ee-builder/src...

Author: gawor
Date: Wed Jan 27 20:09:48 2010
New Revision: 903814

URL: http://svn.apache.org/viewvc?rev=903814&view=rev
Log:
GERONIMO-5051: Fix tld discovery at deployment and runtime

Added:
    geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java   (with props)
    geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java   (with props)
Modified:
    geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/BundleResourceContext.java
    geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java
    geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
    geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java
    geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleResourceFinder.java
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/DelegatingBundle.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
    geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java
    geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/GeronimoTldLocationsCache.java
    geronimo/server/trunk/plugins/wab/TODO
    geronimo/server/trunk/plugins/wab/web-jetty-server/pom.xml
    geronimo/server/trunk/plugins/wab/web-tomcat-server/pom.xml

Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/BundleResourceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/BundleResourceContext.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/BundleResourceContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/BundleResourceContext.java Wed Jan 27 20:09:48 2010
@@ -24,8 +24,16 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
+import org.osgi.framework.Bundle;
+
 public class BundleResourceContext implements ResourceContext {
 
+    private Bundle bundle;
+    
+    public BundleResourceContext(Bundle bundle) {
+        this.bundle = bundle;
+    }
+    
     public void addFile(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException {
     }
 
@@ -62,5 +70,9 @@
     public File getTargetFile(URI targetPath) {
         throw new RuntimeException("getTargetFile() is not supported on Bundle-based deployment");
     }
+    
+    public URL getTargetURL(URI targetPath) {
+        return bundle.getEntry(targetPath.toString());
+    }
 
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/CopyResourceContext.java Wed Jan 27 20:09:48 2010
@@ -23,6 +23,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
 import java.util.jar.JarFile;
@@ -159,6 +160,16 @@
         return new File(baseDir, targetPath.toString());
     }
 
+    public URL getTargetURL(URI targetPath) {
+        File file = getTargetFile(targetPath);
+        try {
+            return file.toURI().toURL();
+        } catch (MalformedURLException e) {
+            // should not happen            
+            throw new RuntimeException("Malformed URL", e);
+        }
+    }
+    
     public void flush() throws IOException {
     }
 

Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/DeploymentContext.java Wed Jan 27 20:09:48 2010
@@ -105,14 +105,34 @@
     private Bundle tempBundle;
 
 
-    public DeploymentContext(File baseDir, File inPlaceConfigurationDir, Environment environment, AbstractName moduleName, ConfigurationModuleType moduleType, Naming naming, ConfigurationManager configurationManager, Collection<Repository> repositories, BundleContext bundleContext) throws DeploymentException {
-        this(baseDir, inPlaceConfigurationDir, environment, moduleName, moduleType, naming, createConfigurationManager(configurationManager, repositories, bundleContext), bundleContext);
+    public DeploymentContext(File baseDir, 
+                             File inPlaceConfigurationDir, 
+                             Environment environment, 
+                             AbstractName moduleName, 
+                             ConfigurationModuleType moduleType, 
+                             Naming naming, 
+                             ConfigurationManager configurationManager, 
+                             Collection<Repository> repositories, 
+                             BundleContext bundleContext) throws DeploymentException {
+        this(baseDir, inPlaceConfigurationDir, environment, moduleName, moduleType, naming, 
+             createConfigurationManager(configurationManager, repositories, bundleContext), bundleContext);
     }
-
-    public DeploymentContext(File baseDir, File inPlaceConfigurationDir, Environment environment, AbstractName moduleName, ConfigurationModuleType moduleType, Naming naming, ConfigurationManager configurationManager, BundleContext bundleContext) throws DeploymentException {        
+    
+    public DeploymentContext(File baseDir, 
+                             File inPlaceConfigurationDir, 
+                             Environment environment, 
+                             AbstractName moduleName, 
+                             ConfigurationModuleType moduleType, 
+                             Naming naming, 
+                             ConfigurationManager configurationManager, 
+                             BundleContext bundleContext) throws DeploymentException {        
         if (environment == null) throw new NullPointerException("environment is null");
         if (moduleType == null) throw new NullPointerException("type is null");
-        if (configurationManager == null) throw new NullPointerException("configurationManager is null");
+        if (configurationManager == null) throw new NullPointerException("configurationManager is null");        
+        if (baseDir == null) throw new NullPointerException("baseDir is null");                
+        if (!baseDir.exists() && !baseDir.mkdirs()) {
+            throw new DeploymentException("Could not create directory for deployment context assembly: " + baseDir);
+        }
         
         this.baseDir = baseDir; 
         this.inPlaceConfigurationDir = inPlaceConfigurationDir;
@@ -122,29 +142,35 @@
         this.environment = environment;
         this.configurationManager = configurationManager;
         this.bundleContext = bundleContext;
-
-        verifyArguments();
-        
-        this.resourceContext = createResourceContext();
-    }
-
-    protected void verifyArguments() throws DeploymentException {
-        if (baseDir == null) {
-            throw new NullPointerException("baseDir is null");
-        }        
-        if (!baseDir.exists() && !baseDir.mkdirs()) {
-            throw new DeploymentException("Could not create directory for deployment context assembly: " + baseDir);
-        }
-    }
-    
-    protected ResourceContext createResourceContext() throws DeploymentException {
+                
         if (null == inPlaceConfigurationDir) {
-            return new CopyResourceContext(this, baseDir);
+            this.resourceContext = new CopyResourceContext(this, baseDir);
         } else {
-            return new InPlaceResourceContext(this, inPlaceConfigurationDir);
+            this.resourceContext = new InPlaceResourceContext(this, inPlaceConfigurationDir);
         }
     }
-    
+
+    // For sub-classes only 
+    protected DeploymentContext(File baseDir, 
+                                File inPlaceConfigurationDir, 
+                                Environment environment, 
+                                AbstractName moduleName, 
+                                ConfigurationModuleType moduleType, 
+                                Naming naming, 
+                                ConfigurationManager configurationManager, 
+                                ResourceContext resourceContext,
+                                BundleContext bundleContext) throws DeploymentException {                
+        this.baseDir = baseDir; 
+        this.inPlaceConfigurationDir = inPlaceConfigurationDir;
+        this.moduleName = moduleName;
+        this.naming = naming;
+        this.moduleType = moduleType;
+        this.environment = environment;
+        this.configurationManager = configurationManager;
+        this.resourceContext = resourceContext;
+        this.bundleContext = bundleContext;
+    }
+        
     private static ConfigurationManager createConfigurationManager(ConfigurationManager configurationManager, Collection<Repository> repositories, BundleContext bundleContext) {
         return new DeploymentConfigurationManager(configurationManager, repositories, bundleContext);
     }
@@ -467,6 +493,10 @@
         return resourceContext.getTargetFile(targetPath);
     }
 
+    public URL getTargetURL(URI targetPath) {
+        return resourceContext.getTargetURL(targetPath);
+    }
+    
     public Bundle getDeploymentBundle() throws DeploymentException {
         return configuration.getBundle();
     }

Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/InPlaceResourceContext.java Wed Jan 27 20:09:48 2010
@@ -19,6 +19,7 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
@@ -111,6 +112,16 @@
         return new File(inPlaceBaseConfigurationUri.resolve(targetPath));
     }
 
+    public URL getTargetURL(URI targetPath) {
+        File file = getTargetFile(targetPath);
+        try {
+            return file.toURI().toURL();
+        } catch (MalformedURLException e) {
+            // should not happen            
+            throw new RuntimeException("Malformed URL", e);
+        }
+    }
+    
     public void flush() throws IOException {
         for (ZipFile zipFile : zipFilesToExpand) {
             String name = zipFile.getName();

Modified: geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-deployment/src/main/java/org/apache/geronimo/deployment/ResourceContext.java Wed Jan 27 20:09:48 2010
@@ -45,5 +45,7 @@
     
     File getTargetFile(URI targetPath);
     
+    URL getTargetURL(URI targetPath);
+    
     void flush() throws IOException;
 }
\ No newline at end of file

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleResourceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleResourceFinder.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleResourceFinder.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleResourceFinder.java Wed Jan 27 20:09:48 2010
@@ -20,8 +20,8 @@
 package org.apache.geronimo.kernel.osgi;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Collection;
 import java.util.Enumeration;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -54,53 +54,60 @@
         this.suffix = suffix.trim();
     }
     
-    public Set<URL> find() {
-        Set<URL> resources = new LinkedHashSet<URL>();
-
-        scanBundleClassPath(resources, bundle);
+    public void find(ResourceFinderCallback callback) throws Exception {
+        scanBundleClassPath(callback, bundle);
         
         Bundle[] fragments = packageAdmin.getFragments(bundle);
         if (fragments != null) {
             for (Bundle fragment : fragments) {
-                scanBundleClassPath(resources, fragment);
+                scanBundleClassPath(callback, fragment);
             }
         }
-        
+    }
+    
+    public Set<URL> find() {
+        Set<URL> resources = new LinkedHashSet<URL>();
+        try {
+            find(new DefaultResourceFinderCallback(resources));
+        } catch (Exception e) {
+            // this should not happen
+            throw new RuntimeException("Resource discovery failed", e);
+        }
         return resources;
     }
     
-    private void scanBundleClassPath(Collection<URL> resources, Bundle bundle) {
+    private void scanBundleClassPath(ResourceFinderCallback callback, Bundle bundle) throws Exception {
         BundleDescription desc = new BundleDescription(bundle.getHeaders());
         List<HeaderEntry> paths = desc.getBundleClassPath();
         if (paths.isEmpty()) {
-            scanDirectory(resources, bundle, prefix);
+            scanDirectory(callback, bundle, prefix);
         } else {
             for (HeaderEntry path : paths) {
                 String name = path.getName();
                 if (name.equals(".") || name.equals("/")) {
                     // scan root
-                    scanDirectory(resources, bundle, prefix);
+                    scanDirectory(callback, bundle, prefix);
                 } else if (name.endsWith(".jar") || name.endsWith(".zip")) {
                     // scan embedded jar/zip
-                    scanZip(resources, bundle, name);
+                    scanZip(callback, bundle, name);
                 } else {
                     // assume it's a directory
-                    scanDirectory(resources, bundle, addSlash(prefix) + name);
+                    scanDirectory(callback, bundle, addSlash(prefix) + name);
                 }
             }
         }
     }
     
-    private void scanDirectory(Collection<URL> resources, Bundle bundle, String basePath) {
+    private void scanDirectory(ResourceFinderCallback callback, Bundle bundle, String basePath) throws Exception {
         Enumeration e = bundle.findEntries(basePath, "*" + suffix, true);
         if (e != null) {
             while (e.hasMoreElements()) {
-                resources.add((URL) e.nextElement());
+                callback.foundDirectory(bundle, basePath, (URL) e.nextElement());
             }
         }
     }
     
-    private void scanZip(Collection<URL> resources, Bundle bundle, String zipName) {   
+    private void scanZip(ResourceFinderCallback callback, Bundle bundle, String zipName) throws Exception {   
         URL zipEntry = bundle.getEntry(zipName);
         if (zipEntry == null) {
             return;
@@ -111,26 +118,7 @@
             while ((entry = in.getNextEntry()) != null) {
                 String name = entry.getName();
                 if (prefixMatches(name) && suffixMatches(name)) {
-                    /**
-                     * XXX: The bundle.getResource() uses bundle class loader to find the resource.
-                     * That means that the returned URL might actually come from another bundle
-                     * that also has a resource with the same name.
-                     * 
-                     * Possible solution 1:
-                     *  Build the URL to the right resource.
-                     *   - Pros: Would not use bundle classloader
-                     *   - Cons: The "bundle" url is not standardized so the implementation might be
-                     *     very framework specific.  
-                     * 
-                     * Possible solution 2:
-                     *   Use bundle.getResources() and find the right resource by comparing urls.
-                     *   - Pros: 
-                     *   - Cons: Uses bundle classloader to find the resources
-                     *           Might need to understand the "bundle" url to compare the returned
-                     *           urls.  
-                     */
-                    URL u = getRightResource(name);
-                    resources.add(u);
+                    callback.foundJar(bundle, zipName, entry);
                 }
             }
         } catch (IOException e) {
@@ -151,20 +139,45 @@
     private boolean suffixMatches(String name) {
         return (suffix.length() == 0) ? true : name.endsWith(suffix);
     }
-        
-    private URL getRightResource(String name) throws IOException {
-        Enumeration e = bundle.getResources(name);
-        URL firstResource = (URL) e.nextElement();
-        if (e.hasMoreElements()) {
-            // TODO: multiple resources found - must pick right one
-        }
-        return firstResource;
-    }
-       
+               
     private static String addSlash(String name) {
         if (!name.endsWith("/")) {
             name = name + "/";
         }
         return name;
     }
+    
+    public interface ResourceFinderCallback {
+        void foundDirectory(Bundle bundle, String baseDir, URL url) throws Exception;
+        
+        void foundJar(Bundle bundle, String jarName, ZipEntry entry) throws Exception;
+    }
+    
+    public static class DefaultResourceFinderCallback implements ResourceFinderCallback {
+
+        private Set<URL> resources;
+        
+        public DefaultResourceFinderCallback() {
+            this(new LinkedHashSet<URL>());
+        }
+        
+        public DefaultResourceFinderCallback(Set<URL> resources) {  
+            this.resources = resources;
+        }
+        
+        public Set<URL> getResources() {
+            return resources;
+        }
+        
+        public void foundDirectory(Bundle bundle, String baseDir, URL url) throws Exception {
+            resources.add(url);
+        }
+
+        public void foundJar(Bundle bundle, String jarName, ZipEntry entry) throws Exception {
+            URL jarURL = bundle.getEntry(jarName);
+            URL url = new URL("jar:" + jarURL.toString() + "!/" + entry.getName());
+            resources.add(url);
+        }
+        
+    }
 }

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/DelegatingBundle.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/DelegatingBundle.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/DelegatingBundle.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/DelegatingBundle.java Wed Jan 27 20:09:48 2010
@@ -57,6 +57,10 @@
         this.bundleContext = new DelegatingBundleContext(this, bundle.getBundleContext());
     }
        
+    public Bundle getMainBundle() {
+        return bundle;
+    }
+    
     public Class<?> loadClass(String name) throws ClassNotFoundException {
         for (Bundle bundle : bundles) {
             try {

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/BundleDeploymentContext.java Wed Jan 27 20:09:48 2010
@@ -24,7 +24,6 @@
 import org.apache.geronimo.deployment.ClassPathList;
 import org.apache.geronimo.deployment.Deployable;
 import org.apache.geronimo.deployment.ModuleList;
-import org.apache.geronimo.deployment.ResourceContext;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.Naming;
@@ -55,21 +54,12 @@
                                    Map messageDestinations,
                                    Bundle bundle) throws DeploymentException {
         super(null, null, 
-              environment, moduleType, naming, configurationManager, bundleContext,
+              environment, moduleType, naming, configurationManager, new BundleResourceContext(bundle), bundleContext,
               serverName, baseName, transactionManagerObjectName, connectionTrackerObjectName, 
               corbaGBeanObjectName, messageDestinations);
         this.bundle = bundle;
     }
-
-    @Override
-    protected void verifyArguments() throws DeploymentException {                
-    }
-    
-    @Override
-    protected ResourceContext createResourceContext() throws DeploymentException {
-        return new BundleResourceContext();
-    }
-    
+   
     @Override
     public void initializeConfiguration() throws DeploymentException {
         try {

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARContext.java Wed Jan 27 20:09:48 2010
@@ -22,6 +22,7 @@
 
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.ResourceContext;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.Naming;
@@ -89,8 +90,7 @@
                       AbstractNameQuery transactionManagerObjectName,
                       AbstractNameQuery connectionTrackerObjectName,
                       AbstractNameQuery corbaGBeanObjectName,
-                      Map messageDestinations
-    ) throws DeploymentException {
+                      Map messageDestinations) throws DeploymentException {
         super(baseDir, inPlaceConfigurationDir, environment, baseName, moduleType, naming, configurationManager, bundleContext);
 
         this.serverName = serverName;
@@ -110,6 +110,31 @@
         this.messageDestinations  = new HashMap();
     }
 
+    // For sub-classes only     
+    protected EARContext(File baseDir,
+                         File inPlaceConfigurationDir,
+                         Environment environment,
+                         ConfigurationModuleType moduleType,
+                         Naming naming,
+                         ConfigurationManager configurationManager,
+                         ResourceContext resourceContext,
+                         BundleContext bundleContext,
+                         AbstractNameQuery serverName,
+                         AbstractName baseName,
+                         AbstractNameQuery transactionManagerObjectName,
+                         AbstractNameQuery connectionTrackerObjectName,
+                         AbstractNameQuery corbaGBeanObjectName,
+                         Map messageDestinations) throws DeploymentException {
+        super(baseDir, inPlaceConfigurationDir, environment, baseName, moduleType, naming, 
+              configurationManager, resourceContext, bundleContext);
+
+        this.serverName = serverName;
+        this.transactionManagerObjectName = transactionManagerObjectName;
+        this.connectionTrackerObjectName = connectionTrackerObjectName;
+        this.corbaGBeanObjectName = corbaGBeanObjectName;
+        this.messageDestinations = messageDestinations;
+    }
+    
     public AbstractNameQuery getServerName() {
         return serverName;
     }

Added: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java?rev=903814&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java (added)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java Wed Jan 27 20:09:48 2010
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.jasper.deployment;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.Deployable;
+import org.apache.geronimo.deployment.DeployableBundle;
+import org.apache.geronimo.j2ee.deployment.WebModule;
+import org.apache.geronimo.kernel.osgi.BundleResourceFinder;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+public class BundleTldScanner {
+
+    /**
+     * Scan the module being deployed for JAR files or TLD files in the WEB-INF directory
+     *
+     * @param webModule module being deployed
+     * @return list of the URL(s) for the TLD files in the module
+     * @throws DeploymentException if module cannot be scanned
+     */
+    public List<URL> scanModule(WebModule webModule) throws DeploymentException {
+        Deployable deployable = webModule.getDeployable();
+        if (!(deployable instanceof DeployableBundle)) {
+            throw new IllegalArgumentException("Expected DeployableBundle");
+        }
+        Bundle bundle = ((DeployableBundle) deployable).getBundle();
+        
+        List<URL> modURLs = new ArrayList<URL>();
+        Enumeration e = bundle.findEntries("WEB-INF/", "*.tld", true);
+        if (e != null) {
+            while (e.hasMoreElements()) {
+                modURLs.add((URL) e.nextElement());
+            }
+        }
+        
+        ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
+        PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
+        
+        BundleResourceFinder resourceFinder = new BundleResourceFinder(packageAdmin, bundle, "META-INF/", ".tld");
+        modURLs.addAll(resourceFinder.find());
+        
+        bundle.getBundleContext().ungetService(reference);
+
+        return modURLs;
+    }
+ 
+}

Propchange: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/BundleTldScanner.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java?rev=903814&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java (added)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java Wed Jan 27 20:09:48 2010
@@ -0,0 +1,195 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.jasper.deployment;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.Deployable;
+import org.apache.geronimo.deployment.DeployableJarFile;
+import org.apache.geronimo.j2ee.deployment.WebModule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JarFileTldScanner {
+    
+    private static final Logger log = LoggerFactory.getLogger(JarFileTldScanner.class);
+
+    /**
+     * Scan the module being deployed for JAR files or TLD files in the WEB-INF directory
+     *
+     * @param webModule module being deployed
+     * @return list of the URL(s) for the TLD files in the module
+     * @throws DeploymentException if module cannot be scanned
+     */
+    public List<URL> scanModule(WebModule webModule) throws DeploymentException {
+        log.debug("scanModule( " + webModule.getName() + " ): Entry");
+        
+        Deployable deployable = webModule.getDeployable();
+        if (!(deployable instanceof DeployableJarFile)) {
+            throw new IllegalArgumentException("Expected DeployableJarFile");
+        }
+        JarFile jarFile = ((DeployableJarFile) deployable).getJarFile();
+        List<URL> modURLs = new ArrayList<URL>();
+        try {
+            Enumeration<JarEntry> entries = jarFile.entries();
+            while (entries.hasMoreElements()) {
+                JarEntry jarEntry = entries.nextElement();
+                if (jarEntry.getName().startsWith("WEB-INF/") && jarEntry.getName().endsWith(".tld")) {
+                    File targetFile = webModule.getEarContext().getTargetFile(webModule.resolve(createURI(jarEntry.getName())));
+                    if (targetFile != null) {
+                        modURLs.add(targetFile.toURI().toURL());
+                    }
+                }
+                if (jarEntry.getName().startsWith("WEB-INF/lib/") && jarEntry.getName().endsWith(".jar")) {
+                    File targetFile = webModule.getEarContext().getTargetFile(webModule.resolve(createURI(jarEntry.getName())));
+                    List<URL> jarUrls = scanJAR(new JarFile(targetFile), "META-INF/");
+                    for (URL jarURL : jarUrls) {
+                        modURLs.add(jarURL);
+                    }
+                }
+            }
+        }
+        catch (IOException ioe) {
+            throw new DeploymentException("Could not scan module for TLD files: " + webModule.getName() + " " + ioe.getMessage(), ioe);
+        }
+        catch (Exception e) {
+            throw new DeploymentException("Could not scan module for TLD files: " + webModule.getName() + " " + e.getMessage(), e);
+        }
+
+        log.debug("scanModule() Exit: URL[" + modURLs.size() + "]: " + modURLs.toString());
+        return modURLs;
+    }
+
+    /**
+     * scanJAR(): Scan a JAR files looking for all TLD
+     *
+     * @param jarFile jar file to scan
+     * @param prefix  Optional prefix to limit the search to a specific subdirectory in the JAR file
+     * @return list of the URL(s) for the TLD files in the JAR file
+     * @throws DeploymentException if jar file cannot be scanned
+     */
+    private List<URL> scanJAR(JarFile jarFile, String prefix) throws DeploymentException {
+        log.debug("scanJAR( " + jarFile.getName() + " ): Entry");
+        
+        List<URL> jarURLs = new ArrayList<URL>();
+        try {
+            Enumeration<JarEntry> entries = jarFile.entries();
+            while (entries.hasMoreElements()) {
+                JarEntry jarEntry = entries.nextElement();
+                if (prefix != null) {
+                    if (jarEntry.getName().endsWith(".tld") && jarEntry.getName().startsWith(prefix)) {
+                        jarURLs.add(new URL("jar:file:" + jarFile.getName() + "!/" + jarEntry.getName()));
+                    }
+                } else {
+                    if (jarEntry.getName().endsWith(".tld")) {
+                        jarURLs.add(new URL("jar:file:" + jarFile.getName() + "!/" + jarEntry.getName()));
+                    }
+                }
+            }
+        }
+        catch (MalformedURLException mfe) {
+            throw new DeploymentException("Could not scan JAR file for TLD files: " + jarFile.getName() + " " + mfe.getMessage(), mfe);
+        }
+        catch (Exception e) {
+            throw new DeploymentException("Could not scan JAR file for TLD files: " + jarFile.getName() + " " + e.getMessage(), e);
+        }
+
+        log.debug("scanJAR() Exit: URL[" + jarURLs.size() + "]: " + jarURLs.toString());
+        return jarURLs;
+    }
+
+
+    /**
+     * scanDirectory(): Scan a directory for all TLD files
+     *
+     * @param url URL for the directory to be scanned
+     * @return list of the URL(s) for the TLD files in the directory
+     * @throws DeploymentException if directory cannot be scanned
+     */
+    private List<URL> scanDirectory(URL url) throws DeploymentException {
+        log.debug("scanDirectory( " + url.toString() + " ): Entry");
+
+        List<URL> dirURLs = new ArrayList<URL>();
+        File directory;
+        if (url != null) {
+            if (url.toString().startsWith("jar:file:")) {
+                try {
+                    JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
+                    URL urlJC = jarConnection.getJarFileURL();
+                    URI baseURI = createURI(urlJC.toString());
+                    directory = new File(baseURI);
+                    if (directory.isDirectory()) {
+                        if (directory.canRead()) {
+                            JarFile temp = new JarFile(directory);
+                            List<URL> tempURLs = scanJAR(temp, "META-INF");
+                            for (URL jarURL : tempURLs) {
+                                dirURLs.add(jarURL);
+                            }
+                        } else {
+                            log.warn("Cannot read JAR file: " + url.toString());
+                        }
+                    }
+                }
+                catch (Exception e) {
+                    throw new DeploymentException("Could not scan directory for TLD files: " + url.toString() + " " + e.getMessage(), e);
+                }
+            } else if (url.toString().startsWith("file:")) {
+                try {
+                    URI baseURI = createURI(url.toString());
+                    directory = new File(baseURI);
+                    if (directory.isDirectory() && directory.canRead()) {
+                        File[] children = directory.listFiles();
+                        for (File child : children) {
+                            if (child.getName().endsWith(".tld")) {
+                                dirURLs.add(child.toURI().toURL());
+                            }
+                        }
+                    } else {
+                        log.warn("Cannot read directory: " + url.toString());
+                    }
+                }
+                catch (Exception e) {
+                    throw new DeploymentException("Could not scan directory for TLD files: " + url.toString() + " " + e.getMessage(), e);
+                }
+            } else if (url.toString().startsWith("jar:")) {
+                log.warn("URL type not accounted for: " + url.toString());
+            }
+        }
+
+        log.debug("scanDirectory() Exit: URL[" + dirURLs.size() + "]: " + dirURLs.toString());
+        return dirURLs;
+    }
+    
+    private static URI createURI(String path) throws URISyntaxException {
+        path = path.replaceAll(" ", "%20");
+        return new URI(path);
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JarFileTldScanner.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/JspModuleBuilderExtension.java Wed Jan 27 20:09:48 2010
@@ -17,27 +17,27 @@
 
 package org.apache.geronimo.jasper.deployment;
 
-import java.io.File;
 import java.io.IOException;
-import java.net.JarURLConnection;
-import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Enumeration;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
 import javax.xml.namespace.QName;
+
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.Deployable;
+import org.apache.geronimo.deployment.DeployableBundle;
+import org.apache.geronimo.deployment.DeployableJarFile;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
@@ -59,7 +59,6 @@
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
-import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder;
@@ -91,6 +90,7 @@
 public class JspModuleBuilderExtension implements ModuleBuilderExtension {
 
     private static final Logger log = LoggerFactory.getLogger(JspModuleBuilderExtension.class);
+    
     private static final QName TLIB_VERSION = new QName(SchemaConversionUtils.JAVAEE_NAMESPACE, "tlib-version");
     private static final QName SHORT_NAME = new QName(SchemaConversionUtils.JAVAEE_NAMESPACE, "short-name");
     private static final QName TAG_CLASS = new QName(SchemaConversionUtils.JAVAEE_NAMESPACE, "tag-class");
@@ -233,15 +233,11 @@
                         location = location.substring(1);
                     }
                     try {
-                        File targetFile = webModule.getEarContext().getTargetFile(webModule.resolve(createURI(location)));
-                        if (targetFile != null) {
-                            tldURLs.add(targetFile.toURI().toURL());
+                        URL targetUrl = webModule.getEarContext().getTargetURL(webModule.resolve(createURI(location)));
+                        if (targetUrl != null) {
+                            tldURLs.add(targetUrl);
                         }
-                    }
-                    catch (MalformedURLException mfe) {
-                        throw new DeploymentException("Could not locate TLD file specified in <taglib>: URI: " + uri + " Location: " + location + " " + mfe.getMessage(), mfe);
-                    }
-                    catch (URISyntaxException use) {
+                    } catch (URISyntaxException use) {
                         throw new DeploymentException("Could not locate TLD file specified in <taglib>: URI: " + uri + " Location: " + location + " " + use.getMessage(), use);
                     }
                 }
@@ -253,6 +249,7 @@
         tldURLs.addAll(scanModule(webModule));
 
         // 4. All TLD files in all META-INF(s)
+        /*
         try {
             Enumeration<URL> enumURLs = webModule.getEarContext().getDeploymentBundle().getResources("META-INF");
             if (enumURLs != null) {
@@ -265,7 +262,8 @@
         catch (IOException ioe) {
             throw new DeploymentException("Could not locate TLD files located in META-INF(s) " + ioe.getMessage(), ioe);
         }
-
+        */
+        
         log.debug("getTldFiles() Exit: URL[" + tldURLs.size() + "]: " + tldURLs.toString());
         return tldURLs;
     }
@@ -280,141 +278,17 @@
      * @throws DeploymentException if module cannot be scanned
      */
     private List<URL> scanModule(WebModule webModule) throws DeploymentException {
-        log.debug("scanModule( " + webModule.getName() + " ): Entry");
-
-        List<URL> modURLs = new ArrayList<URL>();
-        try {
-            Enumeration<JarEntry> entries = webModule.getModuleFile().entries();
-            while (entries.hasMoreElements()) {
-                JarEntry jarEntry = entries.nextElement();
-                if (jarEntry.getName().startsWith("WEB-INF/") && jarEntry.getName().endsWith(".tld")) {
-                    File targetFile = webModule.getEarContext().getTargetFile(webModule.resolve(createURI(jarEntry.getName())));
-                    if (targetFile != null) {
-                        modURLs.add(targetFile.toURI().toURL());
-                    }
-                }
-                if (jarEntry.getName().startsWith("WEB-INF/lib/") && jarEntry.getName().endsWith(".jar")) {
-                    File targetFile = webModule.getEarContext().getTargetFile(webModule.resolve(createURI(jarEntry.getName())));
-                    List<URL> jarUrls = scanJAR(new JarFile(targetFile), null);
-                    for (URL jarURL : jarUrls) {
-                        modURLs.add(jarURL);
-                    }
-                }
-            }
-        }
-        catch (IOException ioe) {
-            throw new DeploymentException("Could not scan module for TLD files: " + webModule.getName() + " " + ioe.getMessage(), ioe);
-        }
-        catch (Exception e) {
-            throw new DeploymentException("Could not scan module for TLD files: " + webModule.getName() + " " + e.getMessage(), e);
-        }
-
-        log.debug("scanModule() Exit: URL[" + modURLs.size() + "]: " + modURLs.toString());
-        return modURLs;
-    }
-
-
-    /**
-     * scanJAR(): Scan a JAR files looking for all TLD
-     *
-     * @param jarFile jar file to scan
-     * @param prefix  Optional prefix to limit the search to a specific subdirectory in the JAR file
-     * @return list of the URL(s) for the TLD files in the JAR file
-     * @throws DeploymentException if jar file cannot be scanned
-     */
-    private List<URL> scanJAR(JarFile jarFile, String prefix) throws DeploymentException {
-        log.debug("scanJAR( " + jarFile.getName() + " ): Entry");
-
-        List<URL> jarURLs = new ArrayList<URL>();
-        try {
-            Enumeration<JarEntry> entries = jarFile.entries();
-            while (entries.hasMoreElements()) {
-                JarEntry jarEntry = entries.nextElement();
-                if (prefix != null) {
-                    if (jarEntry.getName().endsWith(".tld") && jarEntry.getName().startsWith(prefix)) {
-                        jarURLs.add(new URL("jar:file:" + jarFile.getName() + "!/" + jarEntry.getName()));
-                    }
-                } else {
-                    if (jarEntry.getName().endsWith(".tld")) {
-                        jarURLs.add(new URL("jar:file:" + jarFile.getName() + "!/" + jarEntry.getName()));
-                    }
-                }
-            }
-        }
-        catch (MalformedURLException mfe) {
-            throw new DeploymentException("Could not scan JAR file for TLD files: " + jarFile.getName() + " " + mfe.getMessage(), mfe);
+        Deployable deployable = webModule.getDeployable();
+        if (deployable instanceof DeployableJarFile) {
+            JarFileTldScanner scanner = new JarFileTldScanner();
+            return scanner.scanModule(webModule);
+        } else if (deployable instanceof DeployableBundle) {
+            BundleTldScanner scanner = new BundleTldScanner();
+            return scanner.scanModule(webModule);
         }
-        catch (Exception e) {
-            throw new DeploymentException("Could not scan JAR file for TLD files: " + jarFile.getName() + " " + e.getMessage(), e);
-        }
-
-        log.debug("scanJAR() Exit: URL[" + jarURLs.size() + "]: " + jarURLs.toString());
-        return jarURLs;
+        return Collections.emptyList();
     }
 
-
-    /**
-     * scanDirectory(): Scan a directory for all TLD files
-     *
-     * @param url URL for the directory to be scanned
-     * @return list of the URL(s) for the TLD files in the directory
-     * @throws DeploymentException if directory cannot be scanned
-     */
-    private List<URL> scanDirectory(URL url) throws DeploymentException {
-        log.debug("scanDirectory( " + url.toString() + " ): Entry");
-
-        List<URL> dirURLs = new ArrayList<URL>();
-        File directory;
-        if (url != null) {
-            if (url.toString().startsWith("jar:file:")) {
-                try {
-                    JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
-                    URL urlJC = jarConnection.getJarFileURL();
-                    URI baseURI = createURI(urlJC.toString());
-                    directory = new File(baseURI);
-                    if (directory.isDirectory()) {
-                        if (directory.canRead()) {
-                            JarFile temp = new JarFile(directory);
-                            List<URL> tempURLs = scanJAR(temp, "META-INF");
-                            for (URL jarURL : tempURLs) {
-                                dirURLs.add(jarURL);
-                            }
-                        } else {
-                            log.warn("Cannot read JAR file: " + url.toString());
-                        }
-                    }
-                }
-                catch (Exception e) {
-                    throw new DeploymentException("Could not scan directory for TLD files: " + url.toString() + " " + e.getMessage(), e);
-                }
-            } else if (url.toString().startsWith("file:")) {
-                try {
-                    URI baseURI = createURI(url.toString());
-                    directory = new File(baseURI);
-                    if (directory.isDirectory() && directory.canRead()) {
-                        File[] children = directory.listFiles();
-                        for (File child : children) {
-                            if (child.getName().endsWith(".tld")) {
-                                dirURLs.add(child.toURI().toURL());
-                            }
-                        }
-                    } else {
-                        log.warn("Cannot read directory: " + url.toString());
-                    }
-                }
-                catch (Exception e) {
-                    throw new DeploymentException("Could not scan directory for TLD files: " + url.toString() + " " + e.getMessage(), e);
-                }
-            } else if (url.toString().startsWith("jar:")) {
-                log.warn("URL type not accounted for: " + url.toString());
-            }
-        }
-
-        log.debug("scanDirectory() Exit: URL[" + dirURLs.size() + "]: " + dirURLs.toString());
-        return dirURLs;
-    }
-
-
     private List<Class> getListenerClasses(WebAppType webApp, WebModule webModule, Collection<URL> urls, Set<String> listenerNames) throws DeploymentException {
         if (log.isDebugEnabled()) {
             log.debug("getListenerClasses( " + webApp.toString() + "," + '\n' +

Modified: geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/GeronimoTldLocationsCache.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/GeronimoTldLocationsCache.java?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/GeronimoTldLocationsCache.java (original)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/GeronimoTldLocationsCache.java Wed Jan 27 20:09:48 2010
@@ -17,29 +17,30 @@
 
 package org.apache.geronimo.jasper;
 
+import java.io.IOException;
 import java.io.InputStream;
-import java.net.JarURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLConnection;
-import java.util.ArrayList;
 import java.util.Enumeration;
-import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
 
 import javax.servlet.ServletContext;
 
+import org.apache.geronimo.kernel.osgi.BundleResourceFinder;
+import org.apache.geronimo.kernel.osgi.DelegatingBundle;
+import org.apache.geronimo.kernel.osgi.BundleResourceFinder.ResourceFinderCallback;
 import org.apache.jasper.Constants;
 import org.apache.jasper.JasperException;
 import org.apache.jasper.compiler.TldLocationsCache;
 import org.apache.jasper.xmlparser.ParserUtils;
 import org.apache.jasper.xmlparser.TreeNode;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleReference;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.InputSource;
@@ -77,9 +78,6 @@
  * to override Jasper's default TldLocationsCache which does not work
  * with Geronimo's MultiParentClassLoader.  Copying was necessary because
  * most of the essential methods and member variables were private.
- *
- * @author Pierre Delisle
- * @author Jan Luehe
  */
 
 public class GeronimoTldLocationsCache extends TldLocationsCache {
@@ -96,12 +94,6 @@
     private static final String FILE_PROTOCOL = "file:";
     private static final String JAR_FILE_SUFFIX = ".jar";
 
-    // Names of JARs that are known not to contain any TLDs
-    private static HashSet<String> noTldJars;
-
-    // Names of JARs that have already been scanned
-    ArrayList<String> scannedJars;
-
     /**
      * The mapping of the 'global' tag library URI to the location (resource
      * path) of the TLD associated with that tag library. The location is
@@ -113,66 +105,16 @@
 
     private boolean initialized;
     private ServletContext ctxt;
-    private boolean redeployMode;
 
     //*********************************************************************
     // Constructor and Initilizations
 
-    /*
-     * Initializes the set of JARs that are known not to contain any TLDs
-     */
-    static {
-        noTldJars = new HashSet<String>();
-        // Misc JARs not included with Tomcat
-        noTldJars.add("ant.jar");
-        noTldJars.add("commons-dbcp.jar");
-        noTldJars.add("commons-beanutils.jar");
-        noTldJars.add("commons-fileupload-1.0.jar");
-        noTldJars.add("commons-pool.jar");
-        noTldJars.add("commons-digester.jar");
-        noTldJars.add("commons-logging.jar");
-        noTldJars.add("commons-collections.jar");
-        noTldJars.add("jmx.jar");
-        noTldJars.add("jmx-tools.jar");
-        noTldJars.add("xercesImpl.jar");
-        noTldJars.add("xmlParserAPIs.jar");
-        noTldJars.add("xml-apis.jar");
-        // JARs from J2SE runtime
-        noTldJars.add("sunjce_provider.jar");
-        noTldJars.add("ldapsec.jar");
-        noTldJars.add("localedata.jar");
-        noTldJars.add("dnsns.jar");
-        noTldJars.add("tools.jar");
-        noTldJars.add("sunpkcs11.jar");
-    }
-
     public GeronimoTldLocationsCache(ServletContext ctxt) {
         super(ctxt);
         this.ctxt = ctxt;
         this.mappings = new Hashtable<String,String[]>();
     }
 
-    /** Constructor.
-     *
-     * @param ctxt the servlet context of the web application in which Jasper
-     * is running
-     * @param redeployMode if true, then the compiler will allow redeploying
-     * a tag library from the same jar, at the expense of slowing down the
-     * server a bit. Note that this may only work on JDK 1.3.1_01a and later,
-     * because of JDK bug 4211817 fixed in this release.
-     * If redeployMode is false, a faster but less capable mode will be used.
-     */
-    /*
-    public GeronimoTldLocationsCache(ServletContext ctxt, boolean redeployMode) {
-        super(ctxt,redeployMode);
-        scannedJars = new ArrayList<String>();
-        this.ctxt = ctxt;
-        this.redeployMode = redeployMode;
-        mappings = new Hashtable<String,String[]>();
-        initialized = false;
-    }
-    */
-
     /**
      * Sets the list of JARs that are known not to contain any TLDs.
      *
@@ -180,13 +122,6 @@
      * known not to contain any TLDs
      */
     public static void setNoTldJars(String jarNames) {
-        if (jarNames != null) {
-            noTldJars.clear();
-            StringTokenizer tokenizer = new StringTokenizer(jarNames, ",");
-            while (tokenizer.hasMoreElements()) {
-                noTldJars.add(tokenizer.nextToken());
-            }
-        }
     }
 
     /**
@@ -216,14 +151,30 @@
         if (initialized) return;
         try {
             processWebDotXml();
-            scanJars(Thread.currentThread().getContextClassLoader());
-            processTldsInFileSystem("/WEB-INF/");
+            Bundle bundle = getBundle();
+            if (bundle != null) {
+                processWebInf(bundle);
+                processClassPath(bundle);
+            }
             initialized = true;
         } catch (Exception ex) {
             throw new JasperException(ex);
         }
     }
 
+    private Bundle getBundle() {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        if (classLoader instanceof BundleReference) {
+            Bundle bundle = ((BundleReference) classLoader).getBundle();
+            if (bundle instanceof DelegatingBundle) {
+                return ((DelegatingBundle) bundle).getMainBundle();
+            } else {
+                return bundle;
+            }
+        }
+        return null;
+    }
+    
     /*
      * Populates taglib map described in web.xml.
      */
@@ -307,118 +258,61 @@
         }
     }
 
-    /**
-     * Scans the given JarURLConnection for TLD files located in META-INF
-     * (or a subdirectory of it), adding an implicit map entry to the taglib
-     * map for any TLD that has a <uri> element.
-     *
-     * @param conn The JarURLConnection to the JAR file to scan
-     * @param ignore true if any exceptions raised when processing the given
-     * JAR should be ignored, false otherwise
-     */
-    private void scanJar(JarURLConnection conn, boolean ignore)
-                throws JasperException {
-
-        JarFile jarFile = null;
-        String resourcePath = conn.getJarFileURL().toString();
-        try {
-            if (redeployMode) {
-                conn.setUseCaches(false);
-            }
-            jarFile = conn.getJarFile();
-            Enumeration<JarEntry> entries = jarFile.entries();
-            while (entries.hasMoreElements()) {
-                JarEntry entry = entries.nextElement();
-                String name = entry.getName();
-                if (!name.startsWith("META-INF/")) continue;
-                if (!name.endsWith(".tld")) continue;
-                InputStream stream = jarFile.getInputStream(entry);
-                try {
-                    String uri = getUriFromTld(resourcePath, stream);
-                    // Add implicit map entry only if its uri is not already
-                    // present in the map
-                    if (uri != null && mappings.get(uri) == null) {
-                        mappings.put(uri, new String[]{ resourcePath, name });
-                    }
-                } finally {
-                    if (stream != null) {
-                        try {
-                            stream.close();
-                        } catch (Throwable t) {
-                            // do nothing
-                        }
-                    }
-                }
-            }
-        } catch (Exception ex) {
-            if (!redeployMode) {
-                // if not in redeploy mode, close the jar in case of an error
-                if (jarFile != null) {
-                    try {
-                        jarFile.close();
-                    } catch (Throwable t) {
-                        // ignore
-                    }
-                }
-            }
-            if (!ignore) {
-                throw new JasperException(ex);
-            }
-        } finally {
-            if (redeployMode) {
-                // if in redeploy mode, always close the jar
-                if (jarFile != null) {
-                    try {
-                        jarFile.close();
-                    } catch (Throwable t) {
-                        // ignore
-                    }
-                }
+    private void processClassPath(Bundle bundle) throws Exception {
+        ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
+        PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
+                
+        BundleResourceFinder resourceFinder = new BundleResourceFinder(packageAdmin, bundle, "META-INF/", ".tld");
+        resourceFinder.find(new ResourceFinderCallback() {
+
+            public void foundDirectory(Bundle bundle, String basePath, URL url) throws Exception {
+                addMapping(url, new String[] {url.getPath(), null});
+            }
+
+            public void foundJar(Bundle bundle, String jarName, ZipEntry entry) throws Exception {
+                URL jarURL = bundle.getEntry(jarName);
+                URL url = new URL("jar:" + jarURL.toString() + "!/" + entry.getName());
+                
+                addMapping(url, new String[] {jarURL.toString(), entry.getName()});
+            }
+            
+        });
+          
+        bundle.getBundleContext().ungetService(reference);
+    }
+
+    private void processWebInf(Bundle bundle) throws JasperException, IOException {
+        Enumeration e = bundle.findEntries("WEB-INF/", "*.tld", true);
+        if (e != null) {
+            while (e.hasMoreElements()) {
+                URL u = (URL) e.nextElement();
+                addMapping(u, new String[] {u.getPath(), null});
             }
         }
     }
 
-    /*
-     * Searches the filesystem under /WEB-INF for any TLD files, and adds
-     * an implicit map entry to the taglib map for any TLD that has a <uri>
-     * element.
-     */
-    private void processTldsInFileSystem(String startPath)
-            throws Exception {
-
-        Set<String> dirList = ctxt.getResourcePaths(startPath);
-        if (dirList != null) {
-            Iterator<String> it = dirList.iterator();
-            while (it.hasNext()) {
-                String path = it.next();
-                if (path.endsWith("/")) {
-                    processTldsInFileSystem(path);
-                }
-                if (!path.endsWith(".tld")) {
-                    continue;
-                }
-                InputStream stream = ctxt.getResourceAsStream(path);
-                String uri = null;
+    private void addMapping(URL url, String[] location) throws JasperException, IOException {
+        String path = url.toString();
+        InputStream stream = url.openStream();
+        String uri = null;
+        try {
+            uri = getUriFromTld(path, stream);
+        } finally {
+            if (stream != null) {
                 try {
-                    uri = getUriFromTld(path, stream);
-                } finally {
-                    if (stream != null) {
-                        try {
-                            stream.close();
-                        } catch (Throwable t) {
-                            // do nothing
-                        }
-                    }
-                }
-                // Add implicit map entry only if its uri is not already
-                // present in the map
-                if (uri != null && mappings.get(uri) == null) {
-                    mappings.put(uri, new String[] { path, null });
+                    stream.close();
+                } catch (Throwable t) {
+                    // do nothing
                 }
             }
         }
+        // Add implicit map entry only if its uri is not already
+        // present in the map
+        if (uri != null && mappings.get(uri) == null) {
+            mappings.put(uri, location);
+        }
     }
-
+    
     /*
      * Returns the value of the uri element of the given TLD, or null if the
      * given TLD does not contain any such element.
@@ -438,85 +332,4 @@
         return null;
     }
 
-    /*
-     * Scans all JARs accessible to the webapp's classloader and its
-     * parent classloaders for TLDs.
-     *
-     * The list of JARs always includes the JARs under WEB-INF/lib, as well as
-     * all shared JARs in the classloader delegation chain of the webapp's
-     * classloader.
-     *
-     * The set of shared JARs to be scanned for TLDs is narrowed down by
-     * the <tt>noTldJars</tt> class variable, which contains the names of JARs
-     * that are known not to contain any TLDs.
-     */
-    private void scanJars(ClassLoader loader) throws Exception {
-
-//        if (loader instanceof MultiParentClassLoader) {
-//            MultiParentClassLoader mutliLoader = (MultiParentClassLoader) loader;
-//            for (ClassLoader parent : mutliLoader.getParents()) {
-//                scanJars(parent);
-//            }
-//        }
-
-//        if (loader instanceof ChildrenConfigurationClassLoader) {
-//            ChildrenConfigurationClassLoader childLoader = (ChildrenConfigurationClassLoader) loader;
-//            ClassLoader parent = childLoader.getParent();
-//            scanJars(parent);
-//        }
-
-        if (loader instanceof URLClassLoader) {
-            URL[] urls = ((URLClassLoader) loader).getURLs();
-            for (int i=0; i<urls.length; i++) {
-                URLConnection conn = urls[i].openConnection();
-                if (conn instanceof JarURLConnection) {
-                    if (needScanJar(loader,
-                                    ((JarURLConnection) conn).getJarFile().getName())) {
-                        scanJar((JarURLConnection) conn, true);
-                        scannedJars.add(((JarURLConnection) conn).getJarFile().getName());
-                    }
-                } else {
-                    String urlStr = urls[i].toString();
-                    if (urlStr.startsWith(FILE_PROTOCOL)
-                            && urlStr.endsWith(JAR_FILE_SUFFIX)
-                            && needScanJar(loader, urlStr)) {
-                        URL jarURL = new URL("jar:" + urlStr + "!/");
-                        scanJar((JarURLConnection) jarURL.openConnection(),
-                                true);
-                        scannedJars.add(urlStr);
-                    }
-                }
-            }
-        }
-    }
-
-    /*
-     * Determines if the JAR file with the given <tt>jarPath</tt> needs to be
-     * scanned for TLDs.
-     *
-     * @param loader The current classloader in the parent chain
-     * @param webappLoader The webapp classloader
-     * @param jarPath The JAR file path
-     *
-     * @return TRUE if the JAR file identified by <tt>jarPath</tt> needs to be
-     * scanned for TLDs, FALSE otherwise
-     */
-    private boolean needScanJar(ClassLoader loader,
-                                String jarPath) {
-        if (scannedJars.contains(jarPath)) {
-            return false;
-        }
-        else if (loader == Thread.currentThread().getContextClassLoader()) {
-            // JARs under WEB-INF/lib must be scanned unconditionally according
-            // to the spec.
-            return true;
-        } else {
-            String jarName = jarPath;
-            int slash = jarPath.lastIndexOf('/');
-            if (slash >= 0) {
-                jarName = jarPath.substring(slash + 1);
-            }
-            return (!noTldJars.contains(jarName));
-        }
-    }
 }

Modified: geronimo/server/trunk/plugins/wab/TODO
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wab/TODO?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wab/TODO (original)
+++ geronimo/server/trunk/plugins/wab/TODO Wed Jan 27 20:09:48 2010
@@ -2,6 +2,5 @@
  - extender needs to start tracking bundles only once kernel is fully initialized (all plugins are loaded)
  - rfc66 contextpath collision detection
  - for collision detection the extender will need to know all the contextPaths of other Java EE apps deployed
- - register ServerContext into service registry (Tomcat & Jetty)
  - extender needs to check/wait for web container to be available
 

Modified: geronimo/server/trunk/plugins/wab/web-jetty-server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wab/web-jetty-server/pom.xml?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wab/web-jetty-server/pom.xml (original)
+++ geronimo/server/trunk/plugins/wab/web-jetty-server/pom.xml Wed Jan 27 20:09:48 2010
@@ -99,6 +99,13 @@
 
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>jasper-deployer</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>web-extender</artifactId>
             <version>${version}</version>
             <type>car</type>

Modified: geronimo/server/trunk/plugins/wab/web-tomcat-server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/wab/web-tomcat-server/pom.xml?rev=903814&r1=903813&r2=903814&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/wab/web-tomcat-server/pom.xml (original)
+++ geronimo/server/trunk/plugins/wab/web-tomcat-server/pom.xml Wed Jan 27 20:09:48 2010
@@ -99,6 +99,13 @@
 
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>jasper-deployer</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>web-extender</artifactId>
             <version>${version}</version>
             <type>car</type>