openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1606604 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/src/main/java/org/apache/webbeans/portable/ webbeans-impl/src/main/java/org/...
Date Sun, 29 Jun 2014 20:49:21 GMT
Author: rmannibucau
Date: Sun Jun 29 20:49:21 2014
New Revision: 1606604

URL: http://svn.apache.org/r1606604
Log:
tck forces to wrap annotatedtype since they implemented equals on a custom annotatedtype using
delegate pattern...

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AnnotatedTypeWrapper.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
    openwebbeans/trunk/webbeans-tck/testng-dev.xml

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1606604&r1=1606603&r2=1606604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Sun Jun 29 20:49:21 2014
@@ -746,7 +746,11 @@ public class BeansDeployer
                 try
                 {
                     //Define annotation type
-                    AnnotatedType<?> annotatedType = annotatedElementFactory.newAnnotatedType(implClass);
+                    AnnotatedType<?> annotatedType = annotatedElementFactory.getAnnotatedType(implClass);
+                    if (annotatedType == null) // mean no annotation created it (normal case)
+                    {
+                        annotatedType = annotatedElementFactory.newAnnotatedType(implClass);
+                    }
 
                     if (annotatedType == null)
                     {

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AnnotatedTypeWrapper.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AnnotatedTypeWrapper.java?rev=1606604&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AnnotatedTypeWrapper.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AnnotatedTypeWrapper.java
Sun Jun 29 20:49:21 2014
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.container;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+// totally useless but TCKs check AT references creating a new instance for each call...
+class AnnotatedTypeWrapper<T> implements AnnotatedType<T>
+{
+    private final AnnotatedType<T> original;
+
+    public AnnotatedTypeWrapper(final AnnotatedType<T> annotatedType)
+    {
+        original = annotatedType;
+    }
+
+    @Override
+    public Class<T> getJavaClass()
+    {
+        return original.getJavaClass();
+    }
+
+    @Override
+    public Set<AnnotatedConstructor<T>> getConstructors()
+    {
+        return original.getConstructors();
+    }
+
+    @Override
+    public Set<AnnotatedMethod<? super T>> getMethods()
+    {
+        return original.getMethods();
+    }
+
+    @Override
+    public Set<AnnotatedField<? super T>> getFields()
+    {
+        return original.getFields();
+    }
+
+    @Override
+    public Type getBaseType()
+    {
+        return original.getBaseType();
+    }
+
+    @Override
+    public Set<Type> getTypeClosure()
+    {
+        return original.getTypeClosure();
+    }
+
+    @Override
+    public <T extends Annotation> T getAnnotation(Class<T> tClass)
+    {
+        return original.getAnnotation(tClass);
+    }
+
+    @Override
+    public Set<Annotation> getAnnotations()
+    {
+        return original.getAnnotations();
+    }
+
+    @Override
+    public boolean isAnnotationPresent(final Class<? extends Annotation> aClass)
+    {
+        return original.isAnnotationPresent(aClass);
+    }
+}

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=1606604&r1=1606603&r2=1606604&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
Sun Jun 29 20:49:21 2014
@@ -1095,8 +1095,9 @@ public class BeanManagerImpl implements 
         addAdditionalAnnotatedType(annotatedType, AnnotatedElementFactory.OWB_DEFAULT_KEY);
     }
 
-    public void addAdditionalAnnotatedType(AnnotatedType<?> annotatedType, String id)
+    public <T> void addAdditionalAnnotatedType(AnnotatedType<T> inAnnotatedType,
String id)
     {
+        final AnnotatedType<T> annotatedType = new AnnotatedTypeWrapper<T>(inAnnotatedType);
         if (annotatedType.getAnnotation(Vetoed.class) != null)
         {
             // we could check package here too but would be a lost of time 99.99% of the
time
@@ -1179,6 +1180,21 @@ public class BeanManagerImpl implements 
         return (AnnotatedType<T>)annotatedTypes.get(id);
     }
 
+    public <T> Iterable<AnnotatedType<T>> getAnnotatedTypes(final Class<T>
type)
+    {
+        final Collection<AnnotatedType<T>> types = new ArrayList<AnnotatedType<T>>(2);
+        types.add(annotatedElementFactory.getAnnotatedType(type));
+        final ConcurrentMap<String, AnnotatedType<?>> aTypes = additionalAnnotatedTypes.get(type);
+        if (types != null)
+        {
+            for (final AnnotatedType at : aTypes.values())
+            {
+                types.add(at);
+            }
+        }
+        return types;
+    }
+
     public void clear()
     {
         additionalAnnotatedTypes.clear();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java?rev=1606604&r1=1606603&r2=1606604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
Sun Jun 29 20:49:21 2014
@@ -38,12 +38,12 @@ import org.apache.webbeans.util.Asserts;
 
 /**
  * Factory for {@link javax.enterprise.inject.spi.Annotated} elements.
- * 
+ *
  * @version $Rev$ $Date$
  */
 public final class AnnotatedElementFactory
 {
-    
+
     public static final String OWB_DEFAULT_KEY = "OWB_DEFAULT_KEY";
 
     // Logger instance
@@ -64,17 +64,17 @@ public final class AnnotatedElementFacto
     //Cache of AnnotatedConstructor
     private ConcurrentMap<Constructor<?>, AnnotatedConstructor<?>> annotatedConstructorCache
=
         new ConcurrentHashMap<Constructor<?>, AnnotatedConstructor<?>>();
-    
+
     //Cache of AnnotatedMethod
     private ConcurrentMap<Method, AnnotatedMethod<?>> annotatedMethodCache =
         new ConcurrentHashMap<Method, AnnotatedMethod<?>>();
-    
+
     //Cache of AnnotatedField
     private ConcurrentMap<Field, AnnotatedField<?>> annotatedFieldCache =
         new ConcurrentHashMap<Field, AnnotatedField<?>>();
 
     private WebBeansContext webBeansContext;
-    
+
     /**
      * No instantiate.
      */

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java?rev=1606604&r1=1606603&r2=1606604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
Sun Jun 29 20:49:21 2014
@@ -191,7 +191,7 @@ public class AfterBeanDiscoveryImpl impl
      */
     public <T> Iterable<AnnotatedType<T>> getAnnotatedTypes(Class<T>
type)
     {
-        return beanManager.getWebBeansContext().getAnnotatedElementFactory().getAnnotatedTypes(type);
+        return beanManager.getAnnotatedTypes(type);
     }
 
 }

Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1606604&r1=1606603&r2=1606604&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original)
+++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Sun Jun 29 20:49:21 2014
@@ -19,7 +19,7 @@
   <test name="JSR-346 TCK">
     <classes>
       <class
-          name="org.jboss.cdi.tck.tests.lookup.dynamic.builtin.BuiltinInstanceTest" />
+          name="org.jboss.cdi.tck.tests.extensions.afterBeanDiscovery.annotated.GetAnnotatedTypesTest"
/>
     </classes>
     <groups>
       <run>



Mime
View raw message