geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r907906 - in /geronimo/server/trunk/plugins: jasper/geronimo-jasper-builder/src/main/java/org/apache/geronimo/jasper/deployment/ jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/ jasper/jasper/ jasper/jasper/src/main/history/...
Date Tue, 09 Feb 2010 03:26:18 GMT
Author: gawor
Date: Tue Feb  9 03:26:16 2010
New Revision: 907906

URL: http://svn.apache.org/viewvc?rev=907906&view=rev
Log:
GERONIMO-5051, GERONIMO-4996: Use the updated Jasper API to discover TLDs for JSTL and Myfaces

Added:
    geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java
  (with props)
    geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldRegistration.java
  (with props)
Removed:
    geronimo/server/trunk/plugins/myfaces/myfaces-jetty-server/
Modified:
    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/jasper/jasper/pom.xml
    geronimo/server/trunk/plugins/jasper/jasper/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/jasper/jasper/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/myfaces/myfaces/pom.xml
    geronimo/server/trunk/plugins/myfaces/myfaces/src/main/history/dependencies.xml
    geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/myfaces/pom.xml

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=907906&r1=907905&r2=907906&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
Tue Feb  9 03:26:16 2010
@@ -56,6 +56,7 @@
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.jasper.JasperServletContextCustomizer;
+import org.apache.geronimo.jasper.TldProvider;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
@@ -73,6 +74,9 @@
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -246,20 +250,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) {
-                while (enumURLs.hasMoreElements()) {
-                    URL enumURL = enumURLs.nextElement();
-                    tldURLs.addAll(scanDirectory(enumURL));
-                }
-            }
-        }
-        catch (IOException ioe) {
-            throw new DeploymentException("Could not locate TLD files located in META-INF(s)
" + ioe.getMessage(), ioe);
-        }
-        */
+        tldURLs.addAll(scanGlobalTlds(webModule.getEarContext().getDeploymentBundle()));
 
         log.debug("getTldFiles() Exit: URL[" + tldURLs.size() + "]: " + tldURLs.toString());
         return tldURLs;
@@ -286,6 +277,29 @@
         return Collections.emptyList();
     }
 
+    private List<URL> scanGlobalTlds(Bundle bundle) throws DeploymentException {
+        BundleContext bundleContext = bundle.getBundleContext();
+        ServiceReference[] references;
+        try {
+            references = bundleContext.getServiceReferences(TldProvider.class.getName(),
null);
+        } catch (InvalidSyntaxException e) {
+            // this should not happen            
+            throw new DeploymentException("Invalid filter expression", e);
+        }
+        List<URL> tldURLs = new ArrayList<URL>();
+        if (references != null) {
+            for (ServiceReference reference : references) {
+                TldProvider provider = (TldProvider) bundleContext.getService(reference);
+                for (TldProvider.TldEntry entry : provider.getTlds()) {
+                    URL url = entry.getURL();
+                    tldURLs.add(url);
+                }
+                bundleContext.ungetService(reference);
+            }
+        } 
+        return tldURLs;
+    }
+    
     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=907906&r1=907905&r2=907906&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
Tue Feb  9 03:26:16 2010
@@ -19,12 +19,11 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.jar.JarFile;
 import java.util.zip.ZipEntry;
 
 import javax.servlet.ServletContext;
@@ -32,18 +31,22 @@
 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.geronimo.kernel.osgi.jar.BundleJarFile;
 import org.apache.jasper.JasperException;
+import org.apache.jasper.compiler.JarResource;
+import org.apache.jasper.compiler.TldLocation;
 import org.apache.jasper.compiler.TldLocationsCache;
+import org.apache.jasper.compiler.WebXml;
 import org.apache.jasper.xmlparser.ParserUtils;
 import org.apache.jasper.xmlparser.TreeNode;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleReference;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.xml.sax.InputSource;
 
 /**
  * A container for all tag libraries that are defined "globally"
@@ -90,9 +93,10 @@
     public static final int ROOT_REL_URI = 1;
     public static final int NOROOT_REL_URI = 2;
 
-    private static final String WEB_XML = "/WEB-INF/web.xml";
-    private static final String FILE_PROTOCOL = "file:";
-    private static final String JAR_FILE_SUFFIX = ".jar";
+    private static final String WEB_INF = "/WEB-INF/";
+    private static final String WEB_INF_LIB = "/WEB-INF/lib/";
+    private static final String JAR_EXT = ".jar";
+    private static final String TLD_EXT = ".tld";
 
     /**
      * The mapping of the 'global' tag library URI to the location (resource
@@ -101,7 +105,7 @@
      *    [0] The location
      *    [1] If the location is a jar file, this is the location of the tld.
      */
-    private Hashtable<String,String[]> mappings;
+    private Hashtable<String, TldLocation> mappings;
 
     private boolean initialized;
     private ServletContext ctxt;
@@ -112,7 +116,7 @@
     public GeronimoTldLocationsCache(ServletContext ctxt) {
         super(ctxt);
         this.ctxt = ctxt;
-        this.mappings = new Hashtable<String,String[]>();
+        this.mappings = new Hashtable<String, TldLocation>();
     }
 
     /**
@@ -140,21 +144,23 @@
      * Returns null if the uri is not associated with any tag library 'exposed'
      * in the web application.
      */
-    public String[] getLocation(String uri) throws JasperException {
+    public TldLocation getLocation(String uri) throws JasperException {
         if (!initialized) {
             init();
         }
-        return (String[]) mappings.get(uri);
+        return mappings.get(uri);
     }
 
     private void init() throws JasperException {
         if (initialized) return;
         try {
-            processWebDotXml();
+            tldScanWebXml();
+            tldScanResourcePaths(WEB_INF);
+
             Bundle bundle = getBundle();
             if (bundle != null) {
-                processWebInf(bundle);
-                processClassPath(bundle);
+                tldScanClassPath(bundle);
+                tldScanGlobal(bundle);
             }
             initialized = true;
         } catch (Exception ex) {
@@ -177,46 +183,21 @@
     
     /*
      * Populates taglib map described in web.xml.
-     */
-    private void processWebDotXml() throws Exception {
-
-        InputStream is = null;
+     * 
+     * This is not kept in sync with o.a.c.startup.TldConfig as the Jasper only
+     * needs the URI to TLD mappings from scan web.xml whereas TldConfig needs
+     * to scan the actual TLD files.
+     */    
+    private void tldScanWebXml() throws Exception {
 
+        WebXml webXml = null;
         try {
-            // Acquire input stream to web application deployment descriptor
-            String altDDName = (String)ctxt.getAttribute(
-                                                    Constants.ALT_DD_ATTR);
-            URL uri = null;
-            if (altDDName != null) {
-                try {
-                    uri = new URL(FILE_PROTOCOL+altDDName.replace('\\', '/'));
-                } catch (MalformedURLException e) {
-                    if (log.isWarnEnabled()) {
-                        log.warn("file not found: " + altDDName);
-                    }
-                }
-            } else {
-                uri = ctxt.getResource(WEB_XML);
-                if (uri == null && log.isWarnEnabled()) {
-                    log.warn("file not found: " + WEB_XML);
-                }
-            }
-
-            if (uri == null) {
-                return;
-            }
-            is = uri.openStream();
-            InputSource ip = new InputSource(is);
-            ip.setSystemId(uri.toExternalForm());
-
+            webXml = new WebXml(ctxt);
+            
             // Parse the web application deployment descriptor
             TreeNode webtld = null;
-            // altDDName is the absolute path of the DD
-            if (altDDName != null) {
-                webtld = new ParserUtils().parseXMLDocument(altDDName, ip);
-            } else {
-                webtld = new ParserUtils().parseXMLDocument(WEB_XML, ip);
-            }
+            webtld = new ParserUtils().parseXMLDocument(webXml.getSystemId(),
+                    webXml.getInputSource());
 
             // Allow taglib to be an element of the root or jsp-config (JSP2.0)
             TreeNode jspConfig = webtld.findChild("jsp-config");
@@ -242,23 +223,60 @@
                     continue;
                 if (uriType(tagLoc) == NOROOT_REL_URI)
                     tagLoc = "/WEB-INF/" + tagLoc;
-                String tagLoc2 = null;
-                if (tagLoc.endsWith(JAR_FILE_SUFFIX)) {
-                    tagLoc = ctxt.getResource(tagLoc).toString();
-                    tagLoc2 = "META-INF/taglib.tld";
+                TldLocation location;
+                if (tagLoc.endsWith(JAR_EXT)) {
+                    location = new TldLocation("META-INF/taglib.tld", ctxt.getResource(tagLoc).toString());
+                } else {
+                    location = new TldLocation(tagLoc);
                 }
-                mappings.put(tagUri, new String[] { tagLoc, tagLoc2 });
+                mappings.put(tagUri, location);
             }
         } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (Throwable t) {}
+            if (webXml != null) {
+                webXml.close();
             }
         }
     }
+    
+    /*
+     * Scans the web application's sub-directory identified by startPath,
+     * along with its sub-directories, for TLDs and adds an implicit map entry
+     * to the taglib map for any TLD that has a <uri> element.
+     *
+     * Initially, rootPath equals /WEB-INF/. The /WEB-INF/classes and
+     * /WEB-INF/lib sub-directories are excluded from the search, as per the
+     * JSP 2.0 spec.
+     * 
+     * Keep code in sync with o.a.c.startup.TldConfig
+     */
+    private void tldScanResourcePaths(String startPath)
+            throws Exception {
 
-    private void processClassPath(Bundle bundle) 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(TLD_EXT)
+                        && (path.startsWith(WEB_INF_LIB)
+                                || path.startsWith("/WEB-INF/classes/"))) {
+                    continue;
+                }
+                if (path.endsWith(TLD_EXT)) {
+                    if (path.startsWith("/WEB-INF/tags/") &&
+                            !path.endsWith("implicit.tld")) {
+                        continue;
+                    }
+                    InputStream stream = ctxt.getResourceAsStream(path);
+                    tldScanStream(stream, new TldLocation(path));
+                } else {
+                    tldScanResourcePaths(path);
+                }
+            }
+        }
+    }    
+    
+    private void tldScanClassPath(Bundle bundle) throws Exception {
         ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
         PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
                 
@@ -266,70 +284,101 @@
         resourceFinder.find(new ResourceFinderCallback() {
 
             public void foundInDirectory(Bundle bundle, String basePath, URL url) throws
Exception {
-                addMapping(url, new String[] {url.getPath(), null});
+                tldScanStream(url, new TldLocation(url.getPath()));
             }
 
             public void foundInJar(Bundle bundle, String jarName, ZipEntry entry, InputStream
in) throws Exception {
-                URL jarURL = bundle.getEntry(jarName);
-                URL url = new URL("jar:" + jarURL.toString() + "!/" + entry.getName());
-                
-                addMapping(url, new String[] {jarURL.toString(), entry.getName()});
+                URL jarURL = bundle.getEntry(jarName); 
+                tldScanStream(in, new TldLocation(entry.getName(), jarURL.toExternalForm()));
             }
             
         });
           
         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});
+   
+    private void tldScanGlobal(Bundle bundle) throws JasperException, IOException, InvalidSyntaxException
{
+        BundleContext bundleContext = bundle.getBundleContext();
+        ServiceReference[] references = bundleContext.getServiceReferences(TldProvider.class.getName(),
null);
+        if (references != null) {
+            for (ServiceReference reference : references) {
+                TldProvider provider = (TldProvider) bundleContext.getService(reference);
+                for (TldProvider.TldEntry entry : provider.getTlds()) {
+                    URL url = entry.getURL();
+                    if (entry.getJarUrl() != null) { 
+                        tldScanStream(url, new TldLocation(entry.getName(), entry.getJarUrl().toExternalForm()));
+                    } else {
+                        tldScanStream(url, new TldLocation(entry.getName(), new BundleJarResource(entry.getBundle())));
+                    }
+                }
+                bundleContext.ungetService(reference);
             }
         }
     }
-
-    private void addMapping(URL url, String[] location) throws JasperException, IOException
{
-        String path = url.toString();
-        InputStream stream = url.openStream();
-        String uri = null;
+    
+    private void tldScanStream(URL url, TldLocation location) throws IOException {
+        InputStream in = url.openStream();
+        tldScanStream(in, location);
+    }
+    
+    /*
+     * Scan the TLD contents in the specified input stream and add any new URIs
+     * to the map.
+     * 
+     * @param resourcePath  Path of the resource
+     * @param entryName     If the resource is a JAR file, the name of the entry
+     *                      in the JAR file
+     * @param stream        The input stream for the resource
+     * @throws IOException
+     */
+    private void tldScanStream(InputStream stream, TldLocation location) throws IOException
{
+        String path = (location.getJarResource() == null) ?  location.getName() : location.getJarResource().getUrl();
         try {
-            uri = getUriFromTld(path, stream);
+            // Parse the tag library descriptor at the specified resource path
+            String uri = null;
+
+            TreeNode tld =
+                new ParserUtils().parseXMLDocument(path, stream);
+            TreeNode uriNode = tld.findChild("uri");
+            if (uriNode != null) {
+                String body = uriNode.getBody();
+                if (body != null)
+                    uri = body;
+            }
+
+            // 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);
+            }
+        } catch (JasperException e) {
+            // Hack - makes exception handling simpler
+            throw new IOException(e);
         } 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, location);
+            try { stream.close(); } catch (IOException ignore) {}
         }
     }
     
-    /*
-     * Returns the value of the uri element of the given TLD, or null if the
-     * given TLD does not contain any such element.
-     */
-    private String getUriFromTld(String resourcePath, InputStream in)
-        throws JasperException
-    {
-        // Parse the tag library descriptor at the specified resource path
-        TreeNode tld = new ParserUtils().parseXMLDocument(resourcePath, in);
-        TreeNode uri = tld.findChild("uri");
-        if (uri != null) {
-            String body = uri.getBody();
-            if (body != null)
-                return body;
+    private static class BundleJarResource implements JarResource {
+               
+        private Bundle bundle;
+        private URL url;
+        
+        public BundleJarResource(Bundle bundle) {           
+            this.bundle = bundle;
+            this.url = bundle.getEntry("/");
+        }
+        
+        public JarFile getJarFile() throws IOException {
+            return new BundleJarFile(bundle);
+        }
+        
+        public String getUrl() {
+            return url.toExternalForm();
+        }
+        
+        public URL getEntry(String name) {
+            return bundle.getEntry(name);
         }
-
-        return null;
     }
-
 }

Added: 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=907906&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java
(added)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldProvider.java
Tue Feb  9 03:26:16 2010
@@ -0,0 +1,62 @@
+/**
+ *  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;
+
+import java.net.URL;
+import java.util.Collection;
+
+import org.osgi.framework.Bundle;
+
+public interface TldProvider {
+    
+    Collection<TldEntry> getTlds();
+
+    public class TldEntry {
+        
+        private URL url;
+        private Bundle bundle;
+        private URL jarUrl;
+        
+        public TldEntry(Bundle bundle, URL url) {
+            this.bundle = bundle;
+            this.url = url;            
+        }
+        
+        public TldEntry(Bundle bundle, URL url, URL jarUrl) {
+            this.bundle = bundle;
+            this.url = url;            
+            this.jarUrl = jarUrl;
+        }
+        
+        public URL getURL() {
+            return url;
+        }
+        
+        public Bundle getBundle() {
+            return bundle;
+        }
+        
+        public URL getJarUrl() {
+            return jarUrl;
+        }
+        
+        public String getName() {
+            return url.getPath();
+        }
+
+    }
+}

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

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

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

Added: geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldRegistration.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldRegistration.java?rev=907906&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldRegistration.java
(added)
+++ geronimo/server/trunk/plugins/jasper/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/TldRegistration.java
Tue Feb  9 03:26:16 2010
@@ -0,0 +1,115 @@
+/**
+ *  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;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.zip.ZipEntry;
+
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.kernel.osgi.BundleResourceFinder;
+import org.apache.geronimo.kernel.osgi.BundleResourceFinder.ResourceFinderCallback;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@GBean
+public class TldRegistration implements GBeanLifecycle {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(TldRegistration.class);
+    
+    private Bundle bundle;
+    private String packageNameList;
+    
+    public TldRegistration(@ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle,
+                           @ParamAttribute(name = "packageNameList") String packageNameList)
throws Exception {
+        this.bundle = bundle;
+        this.packageNameList = packageNameList;
+    }
+    
+    public void doStart() throws Exception {
+        ServiceReference reference = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
+        PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
+        try {
+            registerTlds(packageAdmin);
+        } finally {
+            bundle.getBundleContext().ungetService(reference);
+        }
+    }
+    
+    private void registerTlds(PackageAdmin packageAdmin) throws Exception {
+        String[] packageNames = packageNameList.split(",");
+        for (String packageName : packageNames) {
+            ExportedPackage exportedPackage = packageAdmin.getExportedPackage(packageName.trim());
+            if (exportedPackage == null) {
+                LOGGER.warn("Package {} is not currently exported by any bundle", packageName);
+            } else {
+                Bundle exportingBundle = exportedPackage.getExportingBundle();
+                
+                BundleResourceFinder resourceFinder = new BundleResourceFinder(packageAdmin,
exportingBundle, "META-INF/", ".tld");
+                TldResourceFinderCallback callback = new TldResourceFinderCallback();
+                resourceFinder.find(callback);
+                if (!callback.getTlds().isEmpty()) {
+                    exportingBundle.getBundleContext().registerService(TldProvider.class.getName(),
callback, null);
+                }
+            }
+        }        
+    }
+        
+    public void doFail() {
+    }
+
+    public void doStop() throws Exception {
+    }
+             
+    private class TldResourceFinderCallback implements ResourceFinderCallback, TldProvider
{
+
+        private List<TldProvider.TldEntry> tlds;
+        
+        private TldResourceFinderCallback() {
+            tlds = new ArrayList<TldProvider.TldEntry>();
+        }
+        
+        public Collection<TldProvider.TldEntry> getTlds() {
+            return tlds;
+        }
+        
+        public void foundInDirectory(Bundle bundle, String basePath, URL url) throws Exception
{
+            LOGGER.debug("Found {} TLD in bundle {}", url, bundle);
+            tlds.add(new TldProvider.TldEntry(bundle, url));
+        }
+
+        public void foundInJar(Bundle bundle, String jarName, ZipEntry entry, InputStream
in) throws Exception {
+            URL jarURL = bundle.getEntry(jarName);
+            URL url = new URL("jar:" + jarURL.toString() + "!/" + entry.getName());
+            LOGGER.debug("Found {} TLD in bundle {}", url, bundle);
+            tlds.add(new TldProvider.TldEntry(bundle, url, jarURL));
+        }
+        
+    }
+
+}

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

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

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

Modified: geronimo/server/trunk/plugins/jasper/jasper/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/jasper/pom.xml?rev=907906&r1=907905&r2=907906&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jasper/jasper/pom.xml (original)
+++ geronimo/server/trunk/plugins/jasper/jasper/pom.xml Tue Feb  9 03:26:16 2010
@@ -75,26 +75,13 @@
             <groupId>org.apache.felix</groupId>
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
-        <!--<dependency>-->
-        <!--<groupId>${tomcatGroupId}</groupId>-->
-        <!--<artifactId>jasper</artifactId>-->
-        <!--</dependency>-->
 
-        <!--<dependency>-->
-        <!--<groupId>${tomcatGroupId}</groupId>-->
-        <!--<artifactId>jasper-jdt</artifactId>-->
-        <!--</dependency>-->
-
-        <!--<dependency>-->
-        <!--<groupId>${tomcatGroupId}</groupId>-->
-        <!--<artifactId>jasper-el</artifactId>-->
-        <!--</dependency>-->
+        <!-- For JSTL support -->
+        <dependency>
+            <groupId>org.apache.geronimo.bundles</groupId>
+            <artifactId>jstl</artifactId>
+        </dependency>
 
-        <!-- are these required? -->
-        <!--<dependency>-->
-        <!--<groupId>${tomcatGroupId}</groupId>-->
-        <!--<artifactId>juli-adapters</artifactId>-->
-        <!--</dependency>-->
     </dependencies>
 
     <build>

Modified: geronimo/server/trunk/plugins/jasper/jasper/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/jasper/src/main/history/dependencies.xml?rev=907906&r1=907905&r2=907906&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jasper/jasper/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugins/jasper/jasper/src/main/history/dependencies.xml Tue Feb
 9 03:26:16 2010
@@ -17,6 +17,11 @@
         <type>jar</type>
     </dependency>
     <dependency>
+        <groupId>org.apache.geronimo.bundles</groupId>
+        <artifactId>jstl</artifactId>
+        <type>jar</type>
+    </dependency>
+    <dependency>
         <groupId>org.apache.geronimo.configs</groupId>
         <artifactId>j2ee-server</artifactId>
         <type>car</type>

Modified: geronimo/server/trunk/plugins/jasper/jasper/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jasper/jasper/src/main/plan/plan.xml?rev=907906&r1=907905&r2=907906&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jasper/jasper/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/jasper/jasper/src/main/plan/plan.xml Tue Feb  9 03:26:16
2010
@@ -25,4 +25,8 @@
 
     <gbean name="JasperJSPFactoryConfigurer" class="org.apache.geronimo.jasper.JasperJSPFactoryConfigurer">
     </gbean>
-</module>
\ No newline at end of file
+
+    <gbean name="JstlTldRegistration" class="org.apache.geronimo.jasper.TldRegistration">
+        <attribute name="packageNameList">org.apache.taglibs.standard</attribute>
+    </gbean>
+</module>

Modified: geronimo/server/trunk/plugins/myfaces/myfaces/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/myfaces/pom.xml?rev=907906&r1=907905&r2=907906&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/myfaces/pom.xml (original)
+++ geronimo/server/trunk/plugins/myfaces/myfaces/pom.xml Tue Feb  9 03:26:16 2010
@@ -53,6 +53,13 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>jasper</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-el_2.2_spec</artifactId>
         </dependency>

Modified: geronimo/server/trunk/plugins/myfaces/myfaces/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/myfaces/src/main/history/dependencies.xml?rev=907906&r1=907905&r2=907906&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/myfaces/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugins/myfaces/myfaces/src/main/history/dependencies.xml Tue Feb
 9 03:26:16 2010
@@ -22,13 +22,13 @@
         <type>jar</type>
     </dependency>
     <dependency>
-        <groupId>org.apache.geronimo.bundles</groupId>
-        <artifactId>jstl</artifactId>
-        <type>jar</type>
+        <groupId>org.apache.geronimo.configs</groupId>
+        <artifactId>j2ee-server</artifactId>
+        <type>car</type>
     </dependency>
     <dependency>
         <groupId>org.apache.geronimo.configs</groupId>
-        <artifactId>j2ee-server</artifactId>
+        <artifactId>jasper</artifactId>
         <type>car</type>
     </dependency>
     <dependency>
@@ -43,21 +43,6 @@
     </dependency>
     <dependency>
         <groupId>org.apache.geronimo.specs</groupId>
-        <artifactId>geronimo-el_2.2_spec</artifactId>
-        <type>jar</type>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.geronimo.specs</groupId>
-        <artifactId>geronimo-jsp_2.2_spec</artifactId>
-        <type>jar</type>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.geronimo.specs</groupId>
-        <artifactId>geronimo-servlet_3.0_spec</artifactId>
-        <type>jar</type>
-    </dependency>
-    <dependency>
-        <groupId>org.apache.geronimo.specs</groupId>
         <artifactId>geronimo-validation_1.0_spec</artifactId>
         <type>jar</type>
     </dependency>

Modified: geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml?rev=907906&r1=907905&r2=907906&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/myfaces/myfaces/src/main/plan/plan.xml Tue Feb  9 03:26:16
2010
@@ -22,4 +22,8 @@
 
     <gbean name="MyFacesLifecycleProviderFactory" class="org.apache.geronimo.myfaces.LifecycleProviderFactoryGBean"/>
 
+    <gbean name="MyfacesTldRegistration" class="org.apache.geronimo.jasper.TldRegistration">
+        <attribute name="packageNameList">org.apache.myfaces.webapp</attribute>
+    </gbean>
+
 </module>

Modified: geronimo/server/trunk/plugins/myfaces/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/pom.xml?rev=907906&r1=907905&r2=907906&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/pom.xml (original)
+++ geronimo/server/trunk/plugins/myfaces/pom.xml Tue Feb  9 03:26:16 2010
@@ -38,7 +38,6 @@
         <module>geronimo-myfaces-builder</module>
         <module>myfaces</module>
         <module>myfaces-deployer</module>
-        <module>myfaces-jetty-server</module>
     </modules>
 
-</project>
\ No newline at end of file
+</project>



Mime
View raw message