openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1823453 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/container/ test/java/org/apache/webbeans/test/interceptors/extension/ test/jav...
Date Wed, 07 Feb 2018 10:56:38 GMT
Author: struberg
Date: Wed Feb  7 10:56:38 2018
New Revision: 1823453

URL: http://svn.apache.org/viewvc?rev=1823453&view=rev
Log:
OWB-1228 add synthetic AnnotatedType id to passivationId

and re-enable producers on custom AnnotatedTypes

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AnnotatedTypeWrapper.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/extension/BeforeBeanDiscoveryImplTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/BeforeBeanDiscoveryTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/addannotated/extension/AddAdditionalAnnotatedTypeExtension.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=1823453&r1=1823452&r2=1823453&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
Wed Feb  7 10:56:38 2018
@@ -25,6 +25,8 @@ import javax.enterprise.inject.spi.Produ
 
 import javax.enterprise.inject.spi.BeanAttributes;
 import javax.enterprise.inject.spi.ProducerFactory;
+
+import org.apache.webbeans.container.AnnotatedTypeWrapper;
 import org.apache.webbeans.util.WebBeansUtil;
 
 
@@ -74,6 +76,17 @@ public class AbstractProducerBean<T> ext
         return ownerComponent;
     }
 
+    @Override
+    protected String providedId()
+    {
+        if (ownerComponent.getAnnotatedType() instanceof AnnotatedTypeWrapper)
+        {
+            return ((AnnotatedTypeWrapper) ownerComponent.getAnnotatedType()).getId();
+        }
+
+        return null;
+    }
+
     /**
      * Check null control.
      * 

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=1823453&r1=1823452&r2=1823453&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
Wed Feb  7 10:56:38 2018
@@ -1965,7 +1965,6 @@ public class BeansDeployer
                 Set<ObserverMethod<?>> observerMethods;
                 AnnotatedType<T> beanAnnotatedType = bean.getAnnotatedType();
                 AnnotatedType<T> defaultAt = webBeansContext.getAnnotatedElementFactory().getAnnotatedType(beanAnnotatedType.getJavaClass());
-                boolean ignoreProducer = defaultAt != beanAnnotatedType && annotatedTypes.containsKey(defaultAt);
                 if(bean.isEnabled())
                 {
                     observerMethods = new ObserverMethodsBuilder<>(webBeansContext,
beanAnnotatedType).defineObserverMethods(bean);
@@ -1976,10 +1975,8 @@ public class BeansDeployer
                 }
 
                 WebBeansContext wbc = bean.getWebBeansContext();
-                Set<ProducerFieldBean<?>> producerFields =
-                        ignoreProducer ? Collections.emptySet() : new ProducerFieldBeansBuilder(wbc,
beanAnnotatedType).defineProducerFields(bean);
-                Set<ProducerMethodBean<?>> producerMethods =
-                        ignoreProducer ? Collections.emptySet() : new ProducerMethodBeansBuilder(wbc,
beanAnnotatedType).defineProducerMethods(bean, producerFields);
+                Set<ProducerFieldBean<?>> producerFields = new ProducerFieldBeansBuilder(wbc,
beanAnnotatedType).defineProducerFields(bean);
+                Set<ProducerMethodBean<?>> producerMethods = new ProducerMethodBeansBuilder(wbc,
beanAnnotatedType).defineProducerMethods(bean, producerFields);
 
                 ManagedBean<T> managedBean = (ManagedBean<T>)bean;
                 Map<ProducerMethodBean<?>,AnnotatedMethod<?>> annotatedMethods
=

Modified: 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=1823453&r1=1823452&r2=1823453&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AnnotatedTypeWrapper.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/AnnotatedTypeWrapper.java
Wed Feb  7 10:56:38 2018
@@ -32,11 +32,13 @@ public class AnnotatedTypeWrapper<T> imp
 {
     private final AnnotatedType<T> original;
     private final Extension source;
+    private final String id;
 
-    public AnnotatedTypeWrapper(Extension source, AnnotatedType<T> annotatedType)
+    public AnnotatedTypeWrapper(Extension source, AnnotatedType<T> annotatedType, String
id)
     {
         this.source = source;
         this.original = annotatedType;
+        this.id = id;
     }
 
     @Override
@@ -45,6 +47,11 @@ public class AnnotatedTypeWrapper<T> imp
         return original.getJavaClass();
     }
 
+    public String getId()
+    {
+        return id;
+    }
+
     @Override
     public Set<AnnotatedConstructor<T>> getConstructors()
     {

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=1823453&r1=1823452&r2=1823453&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 Feb  7 10:56:38 2018
@@ -1330,7 +1330,7 @@ public class BeanManagerImpl implements
             return;
         }
 
-        AnnotatedType<T> annotatedType = new AnnotatedTypeWrapper<>(Extension.class.cast(extension),
inAnnotatedType);
+        AnnotatedType<T> annotatedType = new AnnotatedTypeWrapper<>(Extension.class.cast(extension),
inAnnotatedType, id);
         if (annotatedType.getAnnotation(Vetoed.class) != null)
         {
             // we could check package here too but would be a lost of time 99.99% of the
time

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/extension/BeforeBeanDiscoveryImplTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/extension/BeforeBeanDiscoveryImplTest.java?rev=1823453&r1=1823452&r2=1823453&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/extension/BeforeBeanDiscoveryImplTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/extension/BeforeBeanDiscoveryImplTest.java
Wed Feb  7 10:56:38 2018
@@ -100,7 +100,7 @@ public class BeforeBeanDiscoveryImplTest
             final Set<Annotation> annotations = annotatedType1.getAnnotations();
             annotations.add(new EmptyAnnotationLiteral<InterceptorBinding>() {});
 
-            final AnnotatedType<OwbMethodBinding> annotatedType = new AnnotatedTypeWrapper<OwbMethodBinding>(this,
annotatedType1) {
+            final AnnotatedType<OwbMethodBinding> annotatedType = new AnnotatedTypeWrapper<OwbMethodBinding>(this,
annotatedType1, "x") {
                 @Override
                 public Set<Annotation> getAnnotations()
                 {
@@ -157,7 +157,7 @@ public class BeforeBeanDiscoveryImplTest
             final Set<Annotation> annotations = annotatedType1.getAnnotations();
             annotations.add(new EmptyAnnotationLiteral<InterceptorBinding>() {});
 
-            final AnnotatedType<TheBindingType> annotatedType = new AnnotatedTypeWrapper<TheBindingType>(this,
annotatedType1) {
+            final AnnotatedType<TheBindingType> annotatedType = new AnnotatedTypeWrapper<TheBindingType>(this,
annotatedType1, "x") {
                 @Override
                 public Set<Annotation> getAnnotations()
                 {
@@ -171,7 +171,7 @@ public class BeforeBeanDiscoveryImplTest
                 }
             };
 
-            final AnnotatedTypeWrapper<TheBindingType> wrapper = new AnnotatedTypeWrapper<TheBindingType>(this,
annotatedType) {
+            final AnnotatedTypeWrapper<TheBindingType> wrapper = new AnnotatedTypeWrapper<TheBindingType>(this,
annotatedType, "x") {
                 @Override
                 public Set<AnnotatedMethod<? super TheBindingType>> getMethods()
{
                     final Set<AnnotatedMethod<? super TheBindingType>> methods
= super.getMethods();

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/BeforeBeanDiscoveryTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/BeforeBeanDiscoveryTest.java?rev=1823453&r1=1823452&r2=1823453&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/BeforeBeanDiscoveryTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/BeforeBeanDiscoveryTest.java
Wed Feb  7 10:56:38 2018
@@ -67,18 +67,11 @@ public class BeforeBeanDiscoveryTest ext
     @Test
     public void testAddAdditionalAnnotatedTypeWithPresentClass()
     {
-        Collection<String> beanXmls = new ArrayList<String>();
-
-        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
-        beanClasses.add(AddAdditionalAnnotatedTypeExtension.MyBean.class);
-
         addExtension(new AddAdditionalAnnotatedTypeExtension());
 
-        startContainer(beanClasses, beanXmls);
+        startContainer(AddAdditionalAnnotatedTypeExtension.MyBean.class);
 
-        Bean<?> bean = getBeanManager().getBeans(AddAdditionalAnnotatedTypeExtension.MyBean.class,
new AnnotationLiteral<Default>()
-        {
-        }).iterator().next();
+        Bean<?> bean = getBeanManager().getBeans(AddAdditionalAnnotatedTypeExtension.MyBean.class).iterator().next();
 
         // Bean should not be null, as we added it as an additional annotated
         // type during before bean discovery in the extension

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/addannotated/extension/AddAdditionalAnnotatedTypeExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/addannotated/extension/AddAdditionalAnnotatedTypeExtension.java?rev=1823453&r1=1823452&r2=1823453&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/addannotated/extension/AddAdditionalAnnotatedTypeExtension.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/addannotated/extension/AddAdditionalAnnotatedTypeExtension.java
Wed Feb  7 10:56:38 2018
@@ -18,7 +18,10 @@
  */
 package org.apache.webbeans.test.portable.addannotated.extension;
 
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.BeforeBeanDiscovery;
 import javax.enterprise.inject.spi.Extension;
@@ -29,9 +32,16 @@ import org.apache.webbeans.annotation.Re
 
 public class AddAdditionalAnnotatedTypeExtension implements Extension
 {
+    @RequestScoped
     public static class MyBean
     {
 
+        @Produces
+        @Dependent
+        public String create()
+        {
+            return "dings";
+        }
     }
 
     public static class MyConfigBean1
@@ -53,7 +63,7 @@ public class AddAdditionalAnnotatedTypeE
 
     public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd, BeanManager bm)
     {
-        bbd.addAnnotatedType(bm.createAnnotatedType(MyBean.class));
+        bbd.addAnnotatedType(bm.createAnnotatedType(MyBean.class), "modified");
 
         bbd.addAnnotatedType(MyConfigBean1.class, "hi1")
             .add(RequestedScopeLiteral.INSTANCE);



Mime
View raw message