openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1426627 - in /openwebbeans/branches/owb_1.1.x: ./ webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy/ webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/ ...
Date Fri, 28 Dec 2012 20:50:00 GMT
Author: arne
Date: Fri Dec 28 20:50:00 2012
New Revision: 1426627

URL: http://svn.apache.org/viewvc?rev=1426627&view=rev
Log:
OWB-742: Fixed @Alternative resolution for Instance access

Added:
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBean.java
      - copied unchanged from r1426624, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/AlternativeBean.java
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/SimpleBean.java
      - copied unchanged from r1426624, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/SimpleBean.java
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/SimpleInjectionTarget.java
      - copied unchanged from r1426624, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/SimpleInjectionTarget.java
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/SimpleInterface.java
      - copied unchanged from r1426624, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/SimpleInterface.java
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeInstanceTest.java
      - copied unchanged from r1426624, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeInstanceTest.java
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/simpleAlternative.xml
      - copied unchanged from r1426624, openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/concepts/alternatives/tests/simpleAlternative.xml
Modified:
    openwebbeans/branches/owb_1.1.x/   (props changed)
    openwebbeans/branches/owb_1.1.x/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy/
  (props changed)
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
  (props changed)
    openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/
  (props changed)

Propchange: openwebbeans/branches/owb_1.1.x/
------------------------------------------------------------------------------
  Merged /openwebbeans/trunk:r1426624

Propchange: openwebbeans/branches/owb_1.1.x/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy/
------------------------------------------------------------------------------
  Merged /openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy:r1426624

Modified: openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1426627&r1=1426626&r2=1426627&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Fri Dec 28 20:50:00 2012
@@ -641,11 +641,28 @@ public class InjectionResolver
 
     public <X> Bean<? extends X> resolve(Set<Bean<? extends X>> beans)
     {
-        if (beans == null || beans.isEmpty())
+        Set set = resolveAll(beans);
+        
+        if (set.isEmpty())
         {
             return null;
         }
 
+        if(set.size() > 1)
+        {
+            throwAmbiguousResolutionException(set);
+        }
+
+        return (Bean<? extends X>)set.iterator().next();
+    }
+
+    public <X> Set<Bean<? extends X>> resolveAll(Set<Bean<? extends
X>> beans)
+    {
+        if (beans == null || beans.isEmpty())
+        {
+            return Collections.emptySet();
+        }
+
         Set set = new HashSet<Bean<Object>>();
         for(Bean<? extends X> obj : beans)
         {
@@ -656,7 +673,7 @@ public class InjectionResolver
 
         if (set == null || set.isEmpty())
         {
-            return null;
+            return Collections.emptySet();
         }
 
         if(set.size() > 1)
@@ -664,15 +681,9 @@ public class InjectionResolver
             set = findBySpecialization(set);
         }
 
-        if(set.size() > 1)
-        {
-            throwAmbiguousResolutionException(set);
-        }
-
-        return (Bean<? extends X>)set.iterator().next();
+        return set;
     }
 
-
     private boolean isAltBeanInInjectionPointBDA(String bdaBeansXMLFilePath, Bean<?>
altBean)
     {
 

Modified: openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java?rev=1426627&r1=1426626&r2=1426627&view=diff
==============================================================================
--- openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
(original)
+++ openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/inject/instance/InstanceImpl.java
Fri Dec 28 20:50:00 2012
@@ -31,6 +31,7 @@ import java.util.Set;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.util.TypeLiteral;
 
 import org.apache.webbeans.config.WebBeansContext;
@@ -38,6 +39,7 @@ import org.apache.webbeans.container.Bea
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.util.ClassUtil;
+import org.apache.webbeans.util.InjectionExceptionUtils;
 import org.apache.webbeans.util.OwbCustomObjectInputStream;
 import org.apache.webbeans.util.WebBeansUtil;
 
@@ -107,10 +109,13 @@ class InstanceImpl<T> implements Instanc
         
         Set<Bean<?>> beans = resolveBeans();
 
-        webBeansContext.getResolutionUtil().checkResolvedBeans(beans, ClassUtil.getClazz(injectionClazz),
anns, null);
         BeanManagerImpl beanManager = webBeansContext.getBeanManagerImpl();
-
         Bean<?> bean = beanManager.resolve(beans);
+            
+        if (bean == null)
+        {
+            InjectionExceptionUtils.throwUnsatisfiedResolutionException(ClassUtil.getClazz(injectionClazz),
(InjectionPoint) null, anns);
+        }
 
         // since Instance<T> is Dependent, we we gonna use the parent CreationalContext
by default
         CreationalContext<?> creationalContext = parentCreationalContext;
@@ -147,7 +152,7 @@ class InstanceImpl<T> implements Instanc
 
         InjectionResolver resolver = injectionResolver;
         Set<Bean<?>> beans = resolver.implResolveByType(injectionClazz, injectionPointClazz,
anns);
-        return beans;
+        return resolver.resolveAll(beans);
     }
     
     /**

Propchange: openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
------------------------------------------------------------------------------
  Merged /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java:r1426624

Propchange: openwebbeans/branches/owb_1.1.x/webbeans-impl/src/main/java/org/apache/webbeans/proxy/
------------------------------------------------------------------------------
  Merged /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy:r1426624



Mime
View raw message