[jboss-jira] [JBoss JIRA] Updated: (JBAS-5211) Facelets scanning for .taglib.xml is broken in trunk

Scott M Stark (JIRA) jira-events at lists.jboss.org
Fri Feb 8 01:14:03 EST 2008


     [ http://jira.jboss.com/jira/browse/JBAS-5211?page=all ]

Scott M Stark updated JBAS-5211:
--------------------------------

    Attachment: jsf-facelets-jbas5.jar

The facelets jar was hacked by Ales to include the following two source changes/additions. For CR1 there needs to be a proper patch made and incorporated into a new facelets. We have asked the seam team to track this.

---

package com.sun.facelets.util;

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import java.util.Set;

import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;

/**
 * @author Ales Justin
 */
public final class Classpath
{
   /**
    * Get the virtual file root.
    *
    * @param url the root URL
    * @return actual virtual file from url param
    * @throws IOException for any error
    */
   protected static VirtualFile getRoot(URL url) throws IOException
   {
      String urlString = url.toString();

      if (urlString.startsWith("jar"))
         return VFS.getRoot(url);

      int p = urlString.indexOf(":");
      String file = urlString.substring(p + 1);
      URL vfsurl = null;
      String relative;
      File fp = new File(file);

      if (fp.exists())
      {
         vfsurl = fp.getParentFile().toURL();
         relative = fp.getName();
      }
      else
      {
         File curr = fp;
         relative = fp.getName();
         while ((curr = curr.getParentFile()) != null)
         {
            if (curr.exists())
            {
               vfsurl = curr.toURL();
               break;
            }
            else
            {
               relative = curr.getName() + "/" + relative;
            }
         }
      }

      VirtualFile top = VFS.getRoot(vfsurl);
      return top.getChild(relative);
   }

   public static URL[] search(String prefix, String suffix) throws IOException
   {
      return search(Thread.currentThread().getContextClassLoader(), prefix, suffix);
   }

   public static URL[] search(ClassLoader cl, String prefix, String suffix) throws IOException
   {
      Enumeration e = cl.getResources(prefix);
      Set all = new LinkedHashSet();
      ClasspathVisitor classpathVisitor = new ClasspathVisitor(suffix, all);
      while (e.hasMoreElements())
      {
         URL url = (URL)e.nextElement();
         VirtualFile file = getRoot(url);
         if (file.isLeaf() == false)
            file.visit(classpathVisitor);
      }
      return (URL[])all.toArray(new URL[all.size()]);
   }
}

---

package com.sun.facelets.util;

import java.util.Set;

import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileVisitor;
import org.jboss.virtual.VisitorAttributes;

/**
 * @author Ales Justin
 */
public final class ClasspathVisitor implements VirtualFileVisitor
{
   private String suffix;
   private Set urls;

   public ClasspathVisitor(String suffix, Set urls)
   {
      if (suffix == null)
         throw new IllegalArgumentException("Null suffix");
      this.suffix = suffix;
      if (urls == null)
         throw new IllegalArgumentException("Null urls");
      this.urls = urls;
   }

   private static class MappingVisitorAttributes extends VisitorAttributes
   {
      public MappingVisitorAttributes()
      {
         setIgnoreErrors(true);
         setIncludeHidden(false);
         setIncludeRoot(false);
         setLeavesOnly(false);
         setRecurseFilter(RECURSE_ALL);
      }
   }

   private static final VisitorAttributes MAPPING_ATTRIBUTES = new MappingVisitorAttributes();

   public VisitorAttributes getAttributes()
   {
      return MAPPING_ATTRIBUTES;
   }

   public void visit(VirtualFile vf)
   {
      try
      {
         if (isMapping(vf))
            urls.add(vf.toURL());
      }
      catch (Exception e)
      {
         new RuntimeException("Visit failed: " + e);
      }
   }

   /**
    * Is virtual file a mapping file.
    *
    * @param vf the virtual file
    * @return true if virtual file is mapping
    */
   protected boolean isMapping(VirtualFile vf)
   {
      return vf.getName().endsWith(suffix);
   }
}



> Facelets scanning for .taglib.xml is broken in trunk
> ----------------------------------------------------
>
>                 Key: JBAS-5211
>                 URL: http://jira.jboss.com/jira/browse/JBAS-5211
>             Project: JBoss Application Server
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: ClassLoading
>            Reporter: Charles Crouch
>         Assigned To: Scott M Stark
>            Priority: Blocker
>             Fix For: JBossAS-5.0.0.Beta4
>
>         Attachments: jsf-facelets-jbas5.jar
>
>
> See JBoss Forum thread for details

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list