hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcar...@apache.org
Subject svn commit: r400338 - /jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/ClassFabUtils.java
Date Sat, 06 May 2006 17:07:49 GMT
Author: jcarman
Date: Sat May  6 10:07:48 2006
New Revision: 400338

URL: http://svn.apache.org/viewcvs?rev=400338&view=rev
Log:
HiveMind LoggingInterceptor incompatible with proxies generated by outside means (CGLIB or
Javassist)
PR: HIVEMIND-176

Modified:
    jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/ClassFabUtils.java

Modified: jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/ClassFabUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/ClassFabUtils.java?rev=400338&r1=400337&r2=400338&view=diff
==============================================================================
--- jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/ClassFabUtils.java
(original)
+++ jakarta/hivemind/trunk/framework/src/java/org/apache/hivemind/service/ClassFabUtils.java
Sat May  6 10:07:48 2006
@@ -16,6 +16,7 @@
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
 
 /**
  * Static class containing utility methods.
@@ -106,6 +107,26 @@
     }
 
     /**
+     * Returns the class of an instance.  However, if the instance's class
+     * isn't compatible (externally generated, for instance), then 
+     * <code>interfaceClass</code> is returned instead.
+     * 
+     * @param instance
+     *            the object instance to obtain a class from
+     * @param interfaceClass
+     *            the interface class to return if the instance is not compatible
+     */
+    public static Class getInstanceClass(ClassFab classFab, Object instance, Class interfaceClass)
+    {
+        Class instanceClass = instance.getClass();
+
+        if (!classFab.canConvert(instanceClass))
+            return interfaceClass;
+
+        return instanceClass;
+    }
+
+    /**
      * Returns the class of an instance. However, if the instance is, in fact, a JDK proxy,
returns
      * the interfaceClass (because JDK proxies do not work with Javassist).
      * 
@@ -113,12 +134,13 @@
      *            the object instance to obtain a class from
      * @param interfaceClass
      *            the interface class to return if the instance is a JDK proxy.
+     * @deprecated Please use version which takes a ClassFab object.
      */
-    public static Class getInstanceClass(ClassFab classFab, Object instance, Class interfaceClass)
+    public static Class getInstanceClass(Object instance, Class interfaceClass)
     {
         Class instanceClass = instance.getClass();
 
-        if (!classFab.canConvert(instanceClass))
+        if (Proxy.isProxyClass(instanceClass))
             return interfaceClass;
 
         return instanceClass;



---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message