deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [2/5] deltaspike git commit: DELTASPIKE-823 support stacked proxy classes in ProxyUtils
Date Sat, 14 Feb 2015 10:19:21 GMT
DELTASPIKE-823 support stacked proxy classes in ProxyUtils

Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/a1031ed4
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/a1031ed4
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/a1031ed4

Branch: refs/heads/master
Commit: a1031ed47cf68ccb20162864e649faffdb8ea7ce
Parents: efb2c0d
Author: Thomas Andraschko <tandraschko@apache.org>
Authored: Sat Feb 14 11:00:41 2015 +0100
Committer: Thomas Andraschko <tandraschko@apache.org>
Committed: Sat Feb 14 11:00:41 2015 +0100

----------------------------------------------------------------------
 .../apache/deltaspike/core/util/ProxyUtils.java | 39 +++++++++++++++++---
 1 file changed, 33 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/a1031ed4/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
index 1deb060..03e9f06 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/ProxyUtils.java
@@ -41,11 +41,14 @@ public abstract class ProxyUtils
      */
     public static Class getUnproxiedClass(Class currentClass)
     {
-        if (isProxiedClass(currentClass))
+        Class unproxiedClass = currentClass;
+        
+        while (isProxiedClass(unproxiedClass))
         {
-            return currentClass.getSuperclass();
+            unproxiedClass = unproxiedClass.getSuperclass();
         }
-        return currentClass;
+
+        return unproxiedClass;
     }
 
     /**
@@ -68,13 +71,21 @@ public abstract class ProxyUtils
     {
         List<Class<?>> result = new ArrayList<Class<?>>();
         result.add(proxyClass);
+        
         if (isInterfaceProxy(proxyClass))
         {
             result.addAll(Arrays.asList(proxyClass.getInterfaces()));
         }
         else
         {
-            result.add(proxyClass.getSuperclass());
+            Class unproxiedClass = proxyClass.getSuperclass();
+            result.add(unproxiedClass);
+
+            while (isProxiedClass(unproxiedClass))
+            {
+                unproxiedClass = unproxiedClass.getSuperclass();
+                result.add(unproxiedClass);
+            }
         }
         return result;
     }
@@ -82,7 +93,23 @@ public abstract class ProxyUtils
     public static boolean isInterfaceProxy(Class<?> proxyClass)
     {
         Class<?>[] interfaces = proxyClass.getInterfaces();
-        return Proxy.class.equals(proxyClass.getSuperclass()) &&
-                interfaces != null && interfaces.length > 0;
+        if (Proxy.class.equals(proxyClass.getSuperclass()) &&
+                interfaces != null && interfaces.length > 0)
+        {
+            return true;
+        }
+        
+        if (proxyClass.getName().contains("$$"))
+        {
+            for (Class<?> iface : interfaces)
+            {
+                if (proxyClass.getName().startsWith(iface.getName()))
+                {
+                    return true;
+                }
+            }
+        }
+        
+        return false;
     }
 }


Mime
View raw message