You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2005/08/31 18:32:40 UTC

svn commit: r265527 - /myfaces/share/trunk/src/java/org/apache/myfaces/util/ClassUtils.java

Author: manolito
Date: Wed Aug 31 09:32:30 2005
New Revision: 265527

URL: http://svn.apache.org/viewcvs?rev=265527&view=rev
Log:
fix for MYFACES-208

Modified:
    myfaces/share/trunk/src/java/org/apache/myfaces/util/ClassUtils.java

Modified: myfaces/share/trunk/src/java/org/apache/myfaces/util/ClassUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/share/trunk/src/java/org/apache/myfaces/util/ClassUtils.java?rev=265527&r1=265526&r2=265527&view=diff
==============================================================================
--- myfaces/share/trunk/src/java/org/apache/myfaces/util/ClassUtils.java (original)
+++ myfaces/share/trunk/src/java/org/apache/myfaces/util/ClassUtils.java Wed Aug 31 09:32:30 2005
@@ -23,9 +23,9 @@
 import javax.faces.FacesException;
 import javax.servlet.jsp.el.ELException;
 import java.io.InputStream;
+import java.io.IOException;
 import java.lang.reflect.Array;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 
 /**
@@ -233,6 +233,30 @@
         return stream;
     }
 
+    /**
+     * @param resource       Name of resource(s) to find in classpath
+     * @param defaultObject  The default object to use to determine the class loader (if none associated with current thread.)
+     * @return Iterator over URL Objects
+     */
+    public static Iterator getResources(String resource, Object defaultObject)
+    {
+        try
+        {
+            Enumeration resources = getCurrentLoader(defaultObject).getResources(resource);
+            List lst = new ArrayList();
+            while (resources.hasMoreElements())
+            {
+                lst.add(resources.nextElement());
+            }
+            return lst.iterator();
+        }
+        catch (IOException e)
+        {
+            log.error(e.getMessage(), e);
+            throw new FacesException(e);
+        }
+    }
+
 
     public static Object newInstance(String type)
         throws FacesException
@@ -279,7 +303,7 @@
         catch (ELException e)
         {
             String message = "Cannot coerce " + value.getClass().getName()
-                + " to " + desiredClass.getName();
+                             + " to " + desiredClass.getName();
             log.error(message, e);
             throw new FacesException(message, e);
         }