openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1628704 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/creation/ main/java/org/apache/webbeans/container/ main/java/org/apache/webbeans/portable/ main/java/org/apache/webbeans/util/ test/java/org/apache...
Date Wed, 01 Oct 2014 13:50:21 GMT
Author: rmannibucau
Date: Wed Oct  1 13:50:20 2014
New Revision: 1628704

URL: http://svn.apache.org/r1628704
Log:
tcks: unproxyable exceptions - I guess we copy Weld since this doesn't look that consistent
to respect TCKs + minor check on TypeVariable, surely to do in a better way (using asm?)

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/GenericFactory.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java?rev=1628704&r1=1628703&r2=1628704&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
Wed Oct  1 13:50:20 2014
@@ -138,12 +138,15 @@ public abstract class BeanAttributesBuil
             Set<Type> types = annotated.getTypeClosure();
             this.types.addAll(types);
             Set<String> ignored = webBeansContext.getOpenWebBeansConfiguration().getIgnoredInterfaces();
-            for (Iterator<Type> i = this.types.iterator(); i.hasNext();)
+            if (!ignored.isEmpty())
             {
-                Type t = i.next();
-                if (t instanceof Class && ignored.contains(((Class<?>)t).getName()))
+                for (Iterator<Type> i = this.types.iterator(); i.hasNext(); )
                 {
-                    i.remove();
+                    Type t = i.next();
+                    if (t instanceof Class && ignored.contains(((Class<?>)
t).getName()))
+                    {
+                        i.remove();
+                    }
                 }
             }
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1628704&r1=1628703&r2=1628704&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
Wed Oct  1 13:50:20 2014
@@ -534,11 +534,9 @@ public class BeanManagerImpl implements 
      * {@inheritDoc}
      */
     @Override
-    public <T> AnnotatedType<T> createAnnotatedType(Class<T> type)
+    public <T> AnnotatedType<T> createAnnotatedType(final Class<T> type)
     {
-        AnnotatedType<T> annotatedType = annotatedElementFactory.newAnnotatedType(type);
-
-        return annotatedType;
+        return annotatedElementFactory.newAnnotatedType(type);
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1628704&r1=1628703&r2=1628704&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Wed Oct  1 13:50:20 2014
@@ -18,36 +18,14 @@
  */
 package org.apache.webbeans.container;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.New;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
-
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.InjectionTargetBean;
+import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import javax.enterprise.inject.spi.DefinitionException;
 import org.apache.webbeans.inject.AlternativesManager;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.spi.BDABeansXmlScanner;
@@ -59,6 +37,31 @@ import org.apache.webbeans.util.Generics
 import org.apache.webbeans.util.InjectionExceptionUtil;
 import org.apache.webbeans.util.SingleItemSet;
 import org.apache.webbeans.util.WebBeansUtil;
+
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.UnproxyableResolutionException;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.DefinitionException;
+import javax.enterprise.inject.spi.DeploymentException;
+import javax.enterprise.inject.spi.InjectionPoint;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
 import static org.apache.webbeans.util.InjectionExceptionUtil.throwAmbiguousResolutionException;
 
 /**
@@ -139,6 +142,20 @@ public class InjectionResolver
         {
             throw new WebBeansConfigurationException("Injection point type : " + injectionPoint
+ " needs to define type argument for javax.enterprise.event.Event");
         }
+
+        // not that happy about this check here and at runtime but few TCKs test Weld behavior
only...
+        final Bean<?> bean = resolve(implResolveByType(false, type, injectionPoint.getQualifiers().toArray(new
Annotation[injectionPoint.getQualifiers().size()])));
+        if (bean != null && ManagedBean.class.isInstance(bean))
+        {
+            try
+            {
+                ManagedBean.class.cast(bean).valid();
+            }
+            catch (final UnproxyableResolutionException ure)
+            {
+                throw new DeploymentException(ure);
+            }
+        }
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java?rev=1628704&r1=1628703&r2=1628704&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractAnnotated.java
Wed Oct  1 13:50:20 2014
@@ -46,7 +46,7 @@ abstract class AbstractAnnotated impleme
     
     /**Type closures*/
     private Set<Type> typeClosures = null;
-    
+
     /**Set of annotations*/
     private Set<Annotation> annotations = new HashSet<Annotation>();
 
@@ -226,13 +226,8 @@ abstract class AbstractAnnotated impleme
     
     public String toString()
     {
-        StringBuilder builder = new StringBuilder();
-        
-        builder.append("Base Type : " + baseType.toString() + ",");
-        builder.append("Type Closures : " + typeClosures + ",");
-        builder.append("Annotations : " + annotations.toString());
-        
-        return builder.toString();
+        return ("Base Type : " + baseType.toString() + ",")
+                + "Type Closures : " + typeClosures + ","
+                + "Annotations : " + annotations.toString();
     }
-
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java?rev=1628704&r1=1628703&r2=1628704&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/GenericsUtil.java
Wed Oct  1 13:50:20 2014
@@ -292,7 +292,7 @@ public final class GenericsUtil
             {
                 for (Type upperBound: ((TypeVariable<?>)beanTypeArgument).getBounds())
                 {
-                    if (!isAssignableFrom(swapParams, upperBound, injectionPointTypeArgument))
+                    if (!isAssignableFrom(true, upperBound, injectionPointTypeArgument))
                     {
                         return false;
                     }
@@ -303,7 +303,8 @@ public final class GenericsUtil
             {
                 return false;
             }
-            else if (!isAssignableFrom(isDelegateOrEvent, injectionPointTypeArgument, beanTypeArgument))
+            else if ((!TypeVariable.class.isInstance(beanTypeArgument) || TypeVariable.class.cast(beanTypeArgument).getGenericDeclaration()
!= beanType.getRawType())
+                && !isAssignableFrom(isDelegateOrEvent, injectionPointTypeArgument,
beanTypeArgument))
             {
                 return false;
             }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/GenericFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/GenericFactory.java?rev=1628704&r1=1628703&r2=1628704&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/GenericFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/generics/GenericFactory.java
Wed Oct  1 13:50:20 2014
@@ -18,8 +18,6 @@
  */
 package org.apache.webbeans.test.injection.generics;
 
-import java.util.List;
-
 import javax.enterprise.inject.Produces;
 
 public class GenericFactory {
@@ -35,7 +33,7 @@ public class GenericFactory {
     }
 
     @Produces
-    public Baz<List<BazSubclass>> produceBazBazBazSubclass() {
+    public Baz<Baz<BazSubclass>> produceBazBazBazSubclass() {
         return new Baz();
     }
 }



Mime
View raw message