openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1622749 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/component/creation/ main/java/org/apache/webbeans/event/ test/java/org/apache/webbeans/test/events/injectiontarget/ ...
Date Fri, 05 Sep 2014 17:54:52 GMT
Author: rmannibucau
Date: Fri Sep  5 17:54:52 2014
New Revision: 1622749

URL: http://svn.apache.org/r1622749
Log:
OWB-977 ProcessBeanAttributes for producer - surely few refactoring for common parts + OWB-997
@WithAnnotations was ignoring constructors

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessBeanAttributesTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
Fri Sep  5 17:54:52 2014
@@ -22,6 +22,7 @@ import java.lang.reflect.Field;
 
 import javax.enterprise.context.spi.CreationalContext;
 
+import javax.enterprise.inject.spi.BeanAttributes;
 import javax.enterprise.inject.spi.ProducerFactory;
 
 /**
@@ -40,7 +41,7 @@ public class ProducerFieldBean<T> extend
      * 
      * @param returnType type of the field decleration
      */
-    public ProducerFieldBean(InjectionTargetBean<?> ownerComponent, BeanAttributesImpl<T>
beanAttributes, Class<T> returnType, ProducerFactory<T> producerFactory)
+    public ProducerFieldBean(InjectionTargetBean<?> ownerComponent, BeanAttributes<T>
beanAttributes, Class<T> returnType, ProducerFactory<T> producerFactory)
     {
         super(ownerComponent.getBeanClass(), ownerComponent.getWebBeansContext(), WebBeansType.PRODUCERFIELD,
beanAttributes, returnType, producerFactory);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
Fri Sep  5 17:54:52 2014
@@ -21,6 +21,7 @@ package org.apache.webbeans.component;
 import java.lang.reflect.Method;
 
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanAttributes;
 
 import org.apache.webbeans.component.creation.MethodProducerFactory;
 
@@ -47,7 +48,7 @@ public class ProducerMethodBean<T> exten
      * @param returnType producer method return type
      */
     public <P> ProducerMethodBean(InjectionTargetBean<P> ownerComponent,
-                                  BeanAttributesImpl<T> beanAttributes,
+                                  BeanAttributes<T> beanAttributes,
                                   Class<T> returnType,
                                   MethodProducerFactory<P> producerFactory)
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
Fri Sep  5 17:54:52 2014
@@ -25,6 +25,7 @@ import org.apache.webbeans.spi.ResourceI
 import org.apache.webbeans.spi.api.ResourceReference;
 
 import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.BeanAttributes;
 
 public class ResourceBean<X, T extends Annotation> extends ProducerFieldBean<X>
 {
@@ -33,7 +34,7 @@ public class ResourceBean<X, T extends A
 
     public ResourceBean(InjectionTargetBean<?> ownerComponent,
                         ResourceReference<X, T> resourceReference,
-                        BeanAttributesImpl<X> beanAttributes,
+                        BeanAttributes<X> beanAttributes,
                         Class<X> beanClass)
     {
         super(ownerComponent,

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java
Fri Sep  5 17:54:52 2014
@@ -20,10 +20,10 @@ package org.apache.webbeans.component.cr
 
 import javax.enterprise.inject.spi.AnnotatedMember;
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanAttributes;
 import javax.enterprise.inject.spi.DefinitionException;
 
 import org.apache.webbeans.component.AbstractProducerBean;
-import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.util.Asserts;
 
@@ -32,9 +32,9 @@ public abstract class AbstractProducerBe
 
     protected final InjectionTargetBean<?> parent;
     protected final A annotatedMember;
-    protected final BeanAttributesImpl<T> beanAttributes;
+    protected final BeanAttributes<T> beanAttributes;
 
-    public AbstractProducerBeanBuilder(InjectionTargetBean<?> parent, A annotated,
BeanAttributesImpl<T> beanAttributes)
+    public AbstractProducerBeanBuilder(InjectionTargetBean<?> parent, A annotated,
BeanAttributes<T> beanAttributes)
     {
         Asserts.assertNotNull(parent, "webBeansContext may not be null");
         Asserts.assertNotNull(annotated, "annotated may not be null");

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
Fri Sep  5 17:54:52 2014
@@ -19,15 +19,15 @@
 package org.apache.webbeans.component.creation;
 
 import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.BeanAttributes;
 
-import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ProducerFieldBean;
 
 public class ProducerFieldBeanBuilder<T, P extends ProducerFieldBean<T>> extends
AbstractProducerBeanBuilder<T, AnnotatedField<?>, P>
 {
 
-    public ProducerFieldBeanBuilder(InjectionTargetBean<?> owner, AnnotatedField<?>
annotated, BeanAttributesImpl<T> beanAttributes)
+    public ProducerFieldBeanBuilder(InjectionTargetBean<?> owner, AnnotatedField<?>
annotated, BeanAttributes<T> beanAttributes)
     {
         super(owner, annotated, beanAttributes);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java
Fri Sep  5 17:54:52 2014
@@ -27,6 +27,8 @@ import java.util.Set;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanAttributes;
+import javax.enterprise.inject.spi.DefinitionException;
 import javax.inject.Named;
 
 import org.apache.webbeans.component.BeanAttributesImpl;
@@ -35,6 +37,8 @@ import org.apache.webbeans.component.Pro
 import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.portable.events.ProcessBeanAttributesImpl;
+import org.apache.webbeans.portable.events.generics.GProcessBeanAttributes;
 import org.apache.webbeans.spi.api.ResourceReference;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
@@ -94,12 +98,36 @@ public class ProducerFieldBeansBuilder<T
                             throw new WebBeansConfigurationException("Resource producer annotated
field : " + annotatedField + " can not define EL name");
                         }
                         
-                        BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedField<T>)annotatedField).build();
-                        ResourceBeanBuilder<T, Annotation> resourceBeanCreator
-                            = new ResourceBeanBuilder<T, Annotation>(bean, resourceRef,
annotatedField, beanAttributes);
-                        ResourceBean<T, Annotation> resourceBean = resourceBeanCreator.getBean();
-                        resourceBean.setProducerField(field);
-                        producerBeans.add(resourceBean);                                
           
+                        BeanAttributes<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedField<T>)annotatedField).build();
+
+                        final ProcessBeanAttributesImpl event = new GProcessBeanAttributes(annotatedField.getJavaMember().getType(),
annotatedType, beanAttributes);
+                        try
+                        {
+                            webBeansContext.getBeanManagerImpl().fireEvent(event, true, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
+                        }
+                        catch (final Exception e)
+                        {
+                            throw new DefinitionException("event ProcessBeanAttributes thrown
an exception for " + annotatedType, e);
+                        }
+                        final Throwable definitionError = event.getDefinitionError();
+                        if (definitionError != null)
+                        {
+                            throw new DefinitionException(definitionError);
+                        }
+
+                        if (!event.isVeto())
+                        {
+                            if (event.getAttributes() != beanAttributes)
+                            {
+                                beanAttributes = event.getAttributes();
+                            }
+
+                            ResourceBeanBuilder<T, Annotation> resourceBeanCreator
+                                    = new ResourceBeanBuilder<T, Annotation>(bean,
resourceRef, annotatedField, beanAttributes);
+                            ResourceBean<T, Annotation> resourceBean = resourceBeanCreator.getBean();
+                            resourceBean.setProducerField(field);
+                            producerBeans.add(resourceBean);
+                        }
                     }
                 }
                 else

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
Fri Sep  5 17:54:52 2014
@@ -25,8 +25,8 @@ import java.util.List;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.BeanAttributes;
 
-import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -39,7 +39,7 @@ public class ProducerMethodBeanBuilder<T
     //X TODO arne: this should get evaluated or deleted if not needed anymore
     private boolean specialized;
 
-    public ProducerMethodBeanBuilder(InjectionTargetBean<T> parent, AnnotatedMethod<?>
annotatedMethod, BeanAttributesImpl<T> beanAttributes)
+    public ProducerMethodBeanBuilder(InjectionTargetBean<T> parent, AnnotatedMethod<?>
annotatedMethod, BeanAttributes<T> beanAttributes)
     {
         super(parent, annotatedMethod, beanAttributes);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
Fri Sep  5 17:54:52 2014
@@ -18,11 +18,12 @@
  */
 package org.apache.webbeans.component.creation;
 
-import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.portable.events.ProcessBeanAttributesImpl;
+import org.apache.webbeans.portable.events.generics.GProcessBeanAttributes;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -33,6 +34,8 @@ import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.BeanAttributes;
+import javax.enterprise.inject.spi.DefinitionException;
 import javax.inject.Inject;
 import java.util.HashSet;
 import java.util.Set;
@@ -83,25 +86,51 @@ public class ProducerMethodBeansBuilder<
                     specialize = true;
                 }
                 
-                BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedMethod<T>)annotatedMethod).build();
-                ProducerMethodBeanBuilder<T> producerMethodBeanCreator = new ProducerMethodBeanBuilder<T>(bean,
annotatedMethod, beanAttributes);
-                
-                ProducerMethodBean<T> producerMethodBean = producerMethodBeanCreator.getBean();
-                
-                webBeansContext.getDeploymentValidationService().validateProxyable(producerMethodBean);
+                BeanAttributes beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedMethod<T>)annotatedMethod).build();
+                final ProcessBeanAttributesImpl event = new GProcessBeanAttributes(annotatedMethod.getJavaMember().getReturnType(),
annotatedType, beanAttributes);
+                try
+                {
+                    webBeansContext.getBeanManagerImpl().fireEvent(event, true, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
+                }
+                catch (final Exception e)
+                {
+                    throw new DefinitionException("event ProcessBeanAttributes thrown an
exception for " + annotatedType, e);
+                }
+                final Throwable definitionError = event.getDefinitionError();
+                if (definitionError != null)
+                {
+                    throw new DefinitionException(definitionError);
+                }
 
-                if(specialize)
+                if (!event.isVeto())
                 {
-                    producerMethodBeanCreator.configureProducerSpecialization(producerMethodBean,
(AnnotatedMethod<T>) annotatedMethod);
+                    if (event.getAttributes() != beanAttributes)
+                    {
+                        beanAttributes = event.getAttributes();
+                        if (!webBeansContext.getBeanManagerImpl().isScope(beanAttributes.getScope()))
+                        {
+                            throw new DefinitionException(beanAttributes.getScope() + " is
not a scope");
+                        }
+                    }
+
+                    ProducerMethodBeanBuilder<T> producerMethodBeanCreator = new ProducerMethodBeanBuilder<T>(bean,
annotatedMethod, beanAttributes);
+
+                    ProducerMethodBean<T> producerMethodBean = producerMethodBeanCreator.getBean();
+
+                    webBeansContext.getDeploymentValidationService().validateProxyable(producerMethodBean);
+
+                    if(specialize)
+                    {
+                        producerMethodBeanCreator.configureProducerSpecialization(producerMethodBean,
(AnnotatedMethod<T>) annotatedMethod);
+                    }
+                    producerMethodBean.setCreatorMethod(annotatedMethod.getJavaMember());
+
+                    webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(bean,
+                            producerMethodBean,
+                            AnnotationUtil.asArray(annotatedMethod.getAnnotations()));
+                    WebBeansUtil.checkProducerGenericType(producerMethodBean, annotatedMethod.getJavaMember());
+                    producerBeans.add(producerMethodBean);
                 }
-                producerMethodBean.setCreatorMethod(annotatedMethod.getJavaMember());
-                
-                webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(bean,
-                        producerMethodBean,
-                        AnnotationUtil.asArray(annotatedMethod.getAnnotations()));
-                WebBeansUtil.checkProducerGenericType(producerMethodBean, annotatedMethod.getJavaMember());
-                producerBeans.add(producerMethodBean);
-                
             }
             
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java
Fri Sep  5 17:54:52 2014
@@ -21,8 +21,8 @@ package org.apache.webbeans.component.cr
 import java.lang.annotation.Annotation;
 
 import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.BeanAttributes;
 
-import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.spi.api.ResourceReference;
@@ -32,7 +32,7 @@ public class ResourceBeanBuilder<T, R ex
 
     private ResourceReference<T, R> resourceRef;
 
-    public ResourceBeanBuilder(InjectionTargetBean<?> parent, ResourceReference<T,
R> resourceRef, AnnotatedField<?> annotatedField, BeanAttributesImpl<T> beanAttributes)
+    public ResourceBeanBuilder(InjectionTargetBean<?> parent, ResourceReference<T,
R> resourceRef, AnnotatedField<?> annotatedField, BeanAttributes<T> beanAttributes)
     {
         super(parent, annotatedField, beanAttributes);
         this.resourceRef = resourceRef;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Fri Sep  5 17:54:52 2014
@@ -37,6 +37,7 @@ import javax.enterprise.inject.spi.After
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
 import javax.enterprise.inject.spi.AfterTypeDiscovery;
 import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
@@ -220,6 +221,22 @@ public final class NotificationManager
             }
         }
 
+        Set<AnnotatedConstructor<?>> annotatedConstructors = annotatedType.getConstructors();
+        for (AnnotatedConstructor<?> annotatedConstructor : annotatedConstructors)
+        {
+            if (hasAnnotation(annotatedConstructor.getAnnotations(), withAnnotations))
+            {
+                return true;
+            }
+            for (AnnotatedParameter annotatedParameter : annotatedConstructor.getParameters())
+            {
+                if (hasAnnotation(annotatedParameter.getAnnotations(), withAnnotations))
+                {
+                    return true;
+                }
+            }
+        }
+
         return false;
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessBeanAttributesTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessBeanAttributesTest.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessBeanAttributesTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessBeanAttributesTest.java
Fri Sep  5 17:54:52 2014
@@ -18,14 +18,13 @@
  */
 package org.apache.webbeans.test.events.injectiontarget;
 
-import junit.framework.Assert;
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.junit.Test;
 
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionTarget;
 import javax.enterprise.inject.spi.ProcessBeanAttributes;
 import javax.inject.Inject;
 import java.util.ArrayList;
@@ -44,18 +43,26 @@ public class ProcessBeanAttributesTest e
 
         assertEquals(1, processBeanAttributesExtension.someBean.size());
         assertEquals(1, processBeanAttributesExtension.someOtherBean.size());
+        assertEquals(1, processBeanAttributesExtension.producer.size());
     }
 
     public static class ProcessBeanAttributesExtension implements Extension
     {
         private Collection<ProcessBeanAttributes<?>> someBean = new ArrayList<ProcessBeanAttributes<?>>();
         private Collection<ProcessBeanAttributes<?>> someOtherBean = new ArrayList<ProcessBeanAttributes<?>>();
+        private Collection<ProcessBeanAttributes<?>> producer = new ArrayList<ProcessBeanAttributes<?>>();
 
 
         public void someBean(@Observes ProcessBeanAttributes<SomeBean> pba)
         {
             someBean.add(pba);
         }
+
+        public void producer(@Observes ProcessBeanAttributes<String> pba)
+        {
+            producer.add(pba);
+        }
+
         public void otherBean(@Observes ProcessBeanAttributes<SomeOtherBean> pba)
         {
             someOtherBean.add(pba);
@@ -83,6 +90,11 @@ public class ProcessBeanAttributesTest e
             return meaningOfLife;
         }
 
+        @Produces
+        public String producer() {
+            return "producer";
+        }
+
         public void setMeaningOfLife(int meaningOfLife)
         {
             this.meaningOfLife = meaningOfLife;

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java?rev=1622749&r1=1622748&r2=1622749&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/WithAnnotationTest.java
Fri Sep  5 17:54:52 2014
@@ -23,6 +23,7 @@ import javax.enterprise.event.Observes;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 import javax.enterprise.inject.spi.WithAnnotations;
+import javax.inject.Inject;
 
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
@@ -46,9 +47,9 @@ public class WithAnnotationTest extends 
         WithAnnotationExtension.one = 0;
 
         addExtension(new WithAnnotationExtension());
-        startContainer(WithoutAnyAnnotation.class, WithAnnotatedClass.class, WithAnnotatedField.class,
WithAnnotatedMethod.class);
+        startContainer(WithConstructorAnnotatedClass.class, WithoutAnyAnnotation.class, WithAnnotatedClass.class,
WithAnnotatedField.class, WithAnnotatedMethod.class);
 
-        Assert.assertEquals(3, WithAnnotationExtension.scannedClasses);
+        Assert.assertEquals(4, WithAnnotationExtension.scannedClasses);
         Assert.assertEquals(1, WithAnnotationExtension.one);
     }
 
@@ -75,7 +76,7 @@ public class WithAnnotationTest extends 
     }
 
     @Retention(RetentionPolicy.RUNTIME)
-    @Target({ElementType.FIELD, ElementType.TYPE, ElementType.METHOD})
+    @Target({ElementType.FIELD, ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR,
ElementType.PARAMETER})
     public static @interface MyAnnoation
     {
     }
@@ -110,6 +111,14 @@ public class WithAnnotationTest extends 
         }
     }
 
+    @MyAnnoation
+    public static class WithConstructorAnnotatedClass
+    {
+        @Inject
+        public WithConstructorAnnotatedClass(@MyAnnoation WithAnnotatedClass wac) {
+        }
+    }
+
     @ApplicationScoped
     public static class WithAnnotatedField
     {



Mime
View raw message