You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/09/18 03:50:50 UTC

svn commit: r1386955 - /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java

Author: lu4242
Date: Tue Sep 18 01:50:50 2012
New Revision: 1386955

URL: http://svn.apache.org/viewvc?rev=1386955&view=rev
Log:
synch with shared in core

Modified:
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java?rev=1386955&r1=1386954&r2=1386955&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/MyFacesObjectInputStream.java Tue Sep 18 01:50:50 2012
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectStreamClass;
+import java.lang.reflect.Proxy;
 
 /**
  * Tried to deploy v0.4.2 on JBoss 3.2.1 and had a classloading problem again.
@@ -53,4 +54,36 @@ public class MyFacesObjectInputStream
             return super.resolveClass(desc);
         }
     }
+
+    protected Class resolveProxyClass(String[] interfaces) 
+            throws IOException, ClassNotFoundException
+    {
+        // Only option that would match the current code would be to
+        // expand ClassLoaderExtension to handle 'getProxyClass', which
+        // would break all existing ClassLoaderExtension implementations
+        Class[] cinterfaces = new Class[interfaces.length];
+        for (int i = 0; i < interfaces.length; i++)
+        {
+            cinterfaces[i] = ClassUtils.classForName(interfaces[i]);
+        }
+
+        try
+        {
+            // Try WebApp ClassLoader first
+            return Proxy.getProxyClass(ClassUtils.getContextClassLoader(), cinterfaces);
+        }
+        catch (Exception ex)
+        {
+            // fallback: Try ClassLoader for MyFacesObjectInputStream (i.e. the myfaces.jar lib)
+            try
+            {
+                return Proxy.getProxyClass(
+                        MyFacesObjectInputStream.class.getClassLoader(), cinterfaces);
+            }
+            catch (IllegalArgumentException e)
+            {
+                throw new ClassNotFoundException(e.toString(), e);
+            }
+        }
+    }
 }