openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1528339 - /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
Date Wed, 02 Oct 2013 08:04:37 GMT
Author: rmannibucau
Date: Wed Oct  2 08:04:37 2013
New Revision: 1528339

URL: http://svn.apache.org/r1528339
Log:
better way to find the classloader of a Bean<?> when creating a normal scope proxy

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java?rev=1528339&r1=1528338&r2=1528339&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/NormalScopeProxyFactory.java
Wed Oct  2 08:04:37 2013
@@ -38,6 +38,7 @@ import org.apache.webbeans.exception.Web
 import org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.ExceptionUtil;
+import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.xbean.asm4.ClassWriter;
 import org.apache.xbean.asm4.MethodVisitor;
 import org.apache.xbean.asm4.Opcodes;
@@ -114,7 +115,19 @@ public class NormalScopeProxyFactory ext
 
     public <T> T createNormalScopeProxy(Bean<T> bean)
     {
-        ClassLoader classLoader = bean.getBeanClass().getClassLoader();
+        final ClassLoader classLoader;
+        if (bean.getBeanClass() != null)
+        {
+            classLoader = bean.getBeanClass().getClassLoader();
+        }
+        else if (OwbBean.class.isInstance(bean) && OwbBean.class.cast(bean).getReturnType()
!= null)
+        {
+            classLoader = OwbBean.class.cast(bean).getReturnType().getClassLoader();
+        }
+        else
+        {
+            classLoader = WebBeansUtil.getCurrentClassLoader();
+        }
 
         Class<T> classToProxy;
         if (bean instanceof OwbBean)



Mime
View raw message