openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1797663 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/ configurator/ intercept/ portable/events/discovery/
Date Mon, 05 Jun 2017 13:42:02 GMT
Author: struberg
Date: Mon Jun  5 13:42:01 2017
New Revision: 1797663

URL: http://svn.apache.org/viewvc?rev=1797663&view=rev
Log:
OWB-1186 implement more Configurators

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedConstructorConfiguratorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedFieldConfiguratorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedParameterConfiguratorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedTypeConfiguratorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java

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=1797663&r1=1797662&r2=1797663&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
Mon Jun  5 13:42:01 2017
@@ -103,6 +103,7 @@ import javax.enterprise.inject.spi.Injec
 import javax.enterprise.inject.spi.Interceptor;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.Producer;
+import javax.enterprise.inject.spi.configurator.AnnotatedTypeConfigurator;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
@@ -683,6 +684,17 @@ public class BeansDeployer
                 holder.getId());
         }
 
+        for (AnnotatedTypeConfigurator<?> interceptorATC : event.getInterceptorBindingConfigurators())
+        {
+            webBeansContext.getInterceptorsManager().addInterceptorBindingType((AnnotatedType)
interceptorATC.getAnnotated());
+        }
+
+        for (AnnotatedTypeConfigurator<?> qualifierAt : event.getQualifierConfigurators())
+        {
+            webBeansContext.getBeanManagerImpl().addAdditionalQualifier((AnnotatedType) qualifierAt.getAnnotated());
+
+        }
+
         event.setStarted();
     }
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedConstructorConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedConstructorConfiguratorImpl.java?rev=1797663&r1=1797662&r2=1797663&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedConstructorConfiguratorImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedConstructorConfiguratorImpl.java
Mon Jun  5 13:42:01 2017
@@ -26,40 +26,40 @@ import java.util.List;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
 
-public class AnnotatedConstructorConfiguratorImpl implements AnnotatedConstructorConfigurator
+public class AnnotatedConstructorConfiguratorImpl<T> implements AnnotatedConstructorConfigurator<T>
 {
     @Override
-    public AnnotatedConstructor getAnnotated()
+    public AnnotatedConstructor<T> getAnnotated()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedConstructorConfigurator add(Annotation annotation)
+    public AnnotatedConstructorConfigurator<T> add(Annotation annotation)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedConstructorConfigurator remove(Predicate annotation)
+    public AnnotatedConstructorConfigurator<T> remove(Predicate annotation)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedConstructorConfigurator removeAll()
+    public AnnotatedConstructorConfigurator<T> removeAll()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public List<AnnotatedParameterConfigurator> params()
+    public List<AnnotatedParameterConfigurator<T>> params()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public Stream<AnnotatedParameterConfigurator> filterParams(Predicate predicate)
+    public Stream<AnnotatedParameterConfigurator<T>> filterParams(Predicate predicate)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedFieldConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedFieldConfiguratorImpl.java?rev=1797663&r1=1797662&r2=1797663&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedFieldConfiguratorImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedFieldConfiguratorImpl.java
Mon Jun  5 13:42:01 2017
@@ -23,28 +23,28 @@ import javax.enterprise.inject.spi.confi
 import java.lang.annotation.Annotation;
 import java.util.function.Predicate;
 
-public class AnnotatedFieldConfiguratorImpl implements AnnotatedFieldConfigurator
+public class AnnotatedFieldConfiguratorImpl<T> implements AnnotatedFieldConfigurator<T>
 {
     @Override
-    public AnnotatedField getAnnotated()
+    public AnnotatedField<T> getAnnotated()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedFieldConfigurator add(Annotation annotation)
+    public AnnotatedFieldConfigurator<T> add(Annotation annotation)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedFieldConfigurator remove(Predicate annotation)
+    public AnnotatedFieldConfigurator<T> remove(Predicate annotation)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedFieldConfigurator removeAll()
+    public AnnotatedFieldConfigurator<T> removeAll()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java?rev=1797663&r1=1797662&r2=1797663&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedMethodConfiguratorImpl.java
Mon Jun  5 13:42:01 2017
@@ -26,40 +26,40 @@ import java.util.List;
 import java.util.function.Predicate;
 import java.util.stream.Stream;
 
-public class AnnotatedMethodConfiguratorImpl implements AnnotatedMethodConfigurator
+public class AnnotatedMethodConfiguratorImpl<T> implements AnnotatedMethodConfigurator<T>
 {
     @Override
-    public AnnotatedMethod getAnnotated()
+    public AnnotatedMethod<T> getAnnotated()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedMethodConfigurator add(Annotation annotation)
+    public AnnotatedMethodConfigurator<T> add(Annotation annotation)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedMethodConfigurator remove(Predicate annotation)
+    public AnnotatedMethodConfigurator<T> remove(Predicate annotation)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedMethodConfigurator removeAll()
+    public AnnotatedMethodConfigurator<T> removeAll()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public List<AnnotatedParameterConfigurator> params()
+    public List<AnnotatedParameterConfigurator<T>> params()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public Stream<AnnotatedParameterConfigurator> filterParams(Predicate predicate)
+    public Stream<AnnotatedParameterConfigurator<T>> filterParams(Predicate predicate)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedParameterConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedParameterConfiguratorImpl.java?rev=1797663&r1=1797662&r2=1797663&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedParameterConfiguratorImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedParameterConfiguratorImpl.java
Mon Jun  5 13:42:01 2017
@@ -23,28 +23,28 @@ import javax.enterprise.inject.spi.confi
 import java.lang.annotation.Annotation;
 import java.util.function.Predicate;
 
-public class AnnotatedParameterConfiguratorImpl implements AnnotatedParameterConfigurator
+public class AnnotatedParameterConfiguratorImpl<T> implements AnnotatedParameterConfigurator<T>
 {
     @Override
-    public AnnotatedParameter getAnnotated()
+    public AnnotatedParameter<T> getAnnotated()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedParameterConfigurator add(Annotation annotation)
+    public AnnotatedParameterConfigurator<T> add(Annotation annotation)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedParameterConfigurator remove(Predicate annotation)
+    public AnnotatedParameterConfigurator<T> remove(Predicate annotation)
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public AnnotatedParameterConfigurator removeAll()
+    public AnnotatedParameterConfigurator<T> removeAll()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedTypeConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedTypeConfiguratorImpl.java?rev=1797663&r1=1797662&r2=1797663&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedTypeConfiguratorImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/AnnotatedTypeConfiguratorImpl.java
Mon Jun  5 13:42:01 2017
@@ -30,10 +30,10 @@ import java.lang.annotation.Annotation;
 import java.util.Set;
 import java.util.function.Predicate;
 
-public class AnnotatedTypeConfiguratorImpl implements AnnotatedTypeConfigurator
+public class AnnotatedTypeConfiguratorImpl<T> implements AnnotatedTypeConfigurator<T>
 {
 
-    private final AnnotatedTypeImpl<?> annotatedType;
+    private final AnnotatedTypeImpl<T> annotatedType;
 
 
     public AnnotatedTypeConfiguratorImpl(WebBeansContext webBeansContext, AnnotatedType<?>
annotatedType)
@@ -43,46 +43,46 @@ public class AnnotatedTypeConfiguratorIm
 
 
     @Override
-    public AnnotatedType getAnnotated()
+    public AnnotatedType<T> getAnnotated()
     {
         return annotatedType;
     }
 
     @Override
-    public AnnotatedTypeConfigurator add(Annotation annotation)
+    public AnnotatedTypeConfigurator<T> add(Annotation annotation)
     {
         annotatedType.addAnnotation(annotation);
         return this;
     }
 
     @Override
-    public AnnotatedTypeConfigurator remove(Predicate predicate)
+    public AnnotatedTypeConfigurator<T> remove(Predicate predicate)
     {
         annotatedType.getAnnotations().removeIf(predicate);
         return this;
     }
 
     @Override
-    public AnnotatedTypeConfigurator removeAll()
+    public AnnotatedTypeConfigurator<T> removeAll()
     {
         annotatedType.clearAnnotations();
         return this;
     }
 
     @Override
-    public Set<AnnotatedMethodConfigurator> methods()
+    public Set<AnnotatedMethodConfigurator<? super T>> methods()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public Set<AnnotatedFieldConfigurator> fields()
+    public Set<AnnotatedFieldConfigurator<? super T>> fields()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }
 
     @Override
-    public Set<AnnotatedConstructorConfigurator> constructors()
+    public Set<AnnotatedConstructorConfigurator<T>> constructors()
     {
         throw new UnsupportedOperationException("TODO implement CDI 2.0");
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java?rev=1797663&r1=1797662&r2=1797663&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
Mon Jun  5 13:42:01 2017
@@ -319,7 +319,7 @@ public class InterceptorsManager
         Set<Annotation> inherits = additionalInterceptorBindingTypes.get(bindingType);
         if (inherits == null)
         {
-            inherits = new HashSet<Annotation>();
+            inherits = new HashSet<>();
             additionalInterceptorBindingTypes.put(bindingType, inherits);
         }
         Collections.addAll(inherits, inheritsArray);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java?rev=1797663&r1=1797662&r2=1797663&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
Mon Jun  5 13:42:01 2017
@@ -21,7 +21,9 @@ package org.apache.webbeans.portable.eve
 import java.lang.annotation.Annotation;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.BeforeBeanDiscovery;
@@ -48,6 +50,8 @@ public class BeforeBeanDiscoveryImpl ext
     private final WebBeansContext webBeansContext;
     private Extension extension;
     private Map<String, AnnotatedTypeConfiguratorHolder> annotatedTypeConfigurators
= new HashMap<>();
+    private Set<AnnotatedTypeConfigurator<?>> interceptorBindingConfigurators
= new HashSet<>();
+    private Set<AnnotatedTypeConfigurator<?>> qualifierConfigurators = new HashSet<>();
 
     public BeforeBeanDiscoveryImpl(WebBeansContext webBeansContext)
     {
@@ -117,9 +121,12 @@ public class BeforeBeanDiscoveryImpl ext
     {
         checkState();
         beanManager.addAdditionalAnnotatedType(extension, annotatedType, id);
+
+        // and also remove any AnnotatedTypeConfigurator for that combination
+        String key = annotatedType.getJavaClass() + id;
+        annotatedTypeConfigurators.remove(key);
     }
 
-    //X TODO OWB-1182 CDI 2.0
     @Override
     public <T> AnnotatedTypeConfigurator<T> addAnnotatedType(Class<T> clazz,
String id)
     {
@@ -128,8 +135,7 @@ public class BeforeBeanDiscoveryImpl ext
         AnnotatedTypeConfiguratorHolder configuratorHolder = annotatedTypeConfigurators.get(key);
         if (configuratorHolder == null)
         {
-            AnnotatedType<T> initialAnnotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(clazz);
-            AnnotatedTypeConfigurator<T> configurator = new AnnotatedTypeConfiguratorImpl(webBeansContext,
initialAnnotatedType);
+            AnnotatedTypeConfigurator<T> configurator = getAnnotatedTypeConfigurator(clazz);
             configuratorHolder = new AnnotatedTypeConfiguratorHolder(extension, id, configurator);
             annotatedTypeConfigurators.put(key, configuratorHolder);
         }
@@ -137,21 +143,26 @@ public class BeforeBeanDiscoveryImpl ext
         return configuratorHolder.getAnnotatedTypeConfigurator();
     }
 
-
-    //X TODO OWB-1182 CDI 2.0
     @Override
-    public <T extends Annotation> AnnotatedTypeConfigurator<T> configureInterceptorBinding(Class<T>
aClass)
+    public <T extends Annotation> AnnotatedTypeConfigurator<T> configureInterceptorBinding(Class<T>
clazz)
     {
         checkState();
-        throw new UnsupportedOperationException("CDI 2.0 not yet imlemented");
+
+        AnnotatedTypeConfigurator<T> configurator = getAnnotatedTypeConfigurator(clazz);
+        interceptorBindingConfigurators.add(configurator);
+
+        return configurator;
     }
 
-    //X TODO OWB-1182 CDI 2.0
     @Override
-    public <T extends Annotation> AnnotatedTypeConfigurator<T> configureQualifier(Class<T>
aClass)
+    public <T extends Annotation> AnnotatedTypeConfigurator<T> configureQualifier(Class<T>
clazz)
     {
         checkState();
-        throw new UnsupportedOperationException("CDI 2.0 not yet imlemented");
+
+        AnnotatedTypeConfigurator<T> configurator = getAnnotatedTypeConfigurator(clazz);
+        qualifierConfigurators.add(configurator);
+
+        return configurator;
     }
 
     /**
@@ -185,4 +196,19 @@ public class BeforeBeanDiscoveryImpl ext
         return annotatedTypeConfigurators.values();
     }
 
+    public Collection<AnnotatedTypeConfigurator<?>> getInterceptorBindingConfigurators()
+    {
+        return interceptorBindingConfigurators;
+    }
+
+    public Collection<AnnotatedTypeConfigurator<?>> getQualifierConfigurators()
+    {
+        return qualifierConfigurators;
+    }
+
+    private <T> AnnotatedTypeConfigurator<T> getAnnotatedTypeConfigurator(Class<T>
clazz)
+    {
+        AnnotatedType<T> initialAnnotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(clazz);
+        return (AnnotatedTypeConfigurator<T>) new AnnotatedTypeConfiguratorImpl(webBeansContext,
initialAnnotatedType);
+    }
 }



Mime
View raw message