velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r689659 - /velocity/tools/trunk/src/main/java/org/apache/velocity/tools/ClassUtils.java
Date Wed, 27 Aug 2008 23:23:24 GMT
Author: nbubna
Date: Wed Aug 27 16:23:24 2008
New Revision: 689659

URL: http://svn.apache.org/viewvc?rev=689659&view=rev
Log:
if caller is a Class instance, just use that

Modified:
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/ClassUtils.java

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/ClassUtils.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/ClassUtils.java?rev=689659&r1=689658&r2=689659&view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/ClassUtils.java (original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/ClassUtils.java Wed Aug 27
16:23:24 2008
@@ -220,7 +220,8 @@
      * <li>Thread.currentThread().getContextClassLoader().getResource(name)</li>
      * <li>{@link ClassUtils}.class.getClassLoader().getResource(name)</li>
      * <li>{@link ClassUtils}.class.getResource(name)</li>
-     * <li>caller.getClass().getResource(name)</li>
+     * <li>caller.getClass().getResource(name) or, if caller is a Class,
+     *     caller.getResource(name)</li>
      * </ul>
      *
      * @param name The name of the resource to load
@@ -235,9 +236,14 @@
             if (url == null)
             {
                 url = ClassUtils.class.getResource(name);
-                if (url == null)
+                if (url == null && caller != null)
                 {
-                    url = caller.getClass().getResource(name);
+                    Class callingClass = caller.getClass();
+                    if (callingClass == Class.class)
+                    {
+                        callingClass = (Class)caller;
+                    }
+                    url = callingClass.getResource(name);
                 }
             }
         }



Mime
View raw message