openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1576969 - /openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java
Date Wed, 12 Mar 2014 22:41:50 GMT
Author: rmannibucau
Date: Wed Mar 12 22:41:49 2014
New Revision: 1576969

URL: http://svn.apache.org/r1576969
Log:
OWB-939 ensuring we resolve beans from EL with best type we can use to ensure our proxies
are usable even for normal scope beans otherwise we proxy Object which is not compatible with
BeanResolver

Modified:
    openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java

Modified: openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java?rev=1576969&r1=1576968&r2=1576969&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java
(original)
+++ openwebbeans/trunk/webbeans-el22/src/main/java/org/apache/webbeans/el22/WebBeansELResolver.java
Wed Mar 12 22:41:49 2014
@@ -19,6 +19,7 @@
 package org.apache.webbeans.el22;
 
 import java.beans.FeatureDescriptor;
+import java.lang.reflect.Type;
 import java.util.Iterator;
 import java.util.Set;
 
@@ -29,6 +30,7 @@ import javax.enterprise.context.Dependen
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 
+import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.el.ELContextStore;
@@ -165,7 +167,7 @@ public class WebBeansELResolver extends 
         {
             // If no contextualInstance found on the store
             CreationalContext<Object> creationalContext = manager.createCreationalContext(bean);
-            contextualInstance = manager.getReference(bean, Object.class, creationalContext);
+            contextualInstance = manager.getReference(bean, bestType(bean), creationalContext);
             if (contextualInstance != null)
             {
                 context.setPropertyResolved(true);
@@ -176,6 +178,24 @@ public class WebBeansELResolver extends 
         return contextualInstance;
     }
 
+    private static Type bestType(final Bean<?> bean)
+    {
+        if (bean == null)
+        {
+            return Object.class;
+        }
+        final Class<?> bc = bean.getBeanClass();
+        if (bc != null)
+        {
+            return bc;
+        }
+        if (OwbBean.class.isInstance(bean))
+        {
+            return OwbBean.class.cast(bean).getReturnType();
+        }
+        return Object.class;
+    }
+
     /**
      * {@inheritDoc}
      */    



Mime
View raw message