openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1797664 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java portable/events/discovery/AfterBeanDiscoveryImpl.java portable/events/discovery/AfterTypeDiscoveryImpl.java
Date Mon, 05 Jun 2017 13:52:58 GMT
Author: struberg
Date: Mon Jun  5 13:52:57 2017
New Revision: 1797664

URL: http://svn.apache.org/viewvc?rev=1797664&view=rev
Log:
OWB-1186 implement AnnotatedTypeConfigurators in AfterTypeDiscovery

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.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=1797664&r1=1797663&r2=1797664&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:52:57 2017
@@ -737,6 +737,16 @@ public class BeansDeployer
         // reverse to keep "selection" order - decorator and interceptors considers it in
their sorting.
         // NOTE: from here priorityClass.getSorted() MUST NOT be recomputed (ie no priorityClass.add(...))
         Collections.reverse(alternatives);
+
+        for (AnnotatedTypeConfiguratorHolder holder : event.getAnnotatedTypeConfigurators())
+        {
+            manager.addAdditionalAnnotatedType(
+                holder.getExtension(),
+                holder.getAnnotatedTypeConfigurator().getAnnotated(),
+                holder.getId());
+        }
+
+
         event.setStarted();
 
         // we do not need to set back the sortedAlternatives to the AlternativesManager as
the API
@@ -1236,7 +1246,7 @@ public class BeansDeployer
     }
 
     /**
-     * Process any AnnotatedTypes which got added by BeforeBeanDiscovery#addAnnotatedType
+     * Process any AnnotatedTypes which got added by BeforeBeanDiscovery#addAnnotatedType
and other events
      * @param annotatedTypes
      */
     private void addAdditionalAnnotatedTypes(Collection<AnnotatedType<?>> toDeploy,
List<AnnotatedType<?>> annotatedTypes)

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=1797664&r1=1797663&r2=1797664&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
Mon Jun  5 13:52:57 2017
@@ -220,7 +220,7 @@ public class AfterBeanDiscoveryImpl exte
     public <T> AnnotatedType<T> getAnnotatedType(Class<T> type, String
id)
     {
         checkState();
-        return (AnnotatedType<T>) beanManager.getAdditionalAnnotatedType(type, id);
+        return beanManager.getAdditionalAnnotatedType(type, id);
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.java?rev=1797664&r1=1797663&r2=1797664&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.java
Mon Jun  5 13:52:57 2017
@@ -22,9 +22,13 @@ import javax.enterprise.inject.spi.After
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.configurator.AnnotatedTypeConfigurator;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.configurator.AnnotatedTypeConfiguratorImpl;
 import org.apache.webbeans.portable.events.EventBase;
 
 /**
@@ -38,6 +42,7 @@ public class AfterTypeDiscoveryImpl exte
     private final List<Class<?>> sortedInterceptors;
     private final List<Class<?>> sortedDecorators;
     private final List<AnnotatedType<?>> newAt;
+    private Map<String, AnnotatedTypeConfiguratorHolder> annotatedTypeConfigurators
= new HashMap<>();
     private Extension extension;
 
     public AfterTypeDiscoveryImpl(WebBeansContext webBeansContext,
@@ -82,12 +87,20 @@ public class AfterTypeDiscoveryImpl exte
         newAt.add(type);
     }
 
-    //X TODO OWB-1182 CDI 2.0
     @Override
-    public <T> AnnotatedTypeConfigurator<T> addAnnotatedType(Class<T> forClass,
String id)
+    public <T> AnnotatedTypeConfigurator<T> addAnnotatedType(Class<T> clazz,
String id)
     {
         checkState();
-        throw new UnsupportedOperationException("CDI 2.0 not yet imlemented");
+        String key = clazz.getName() + id;
+        AnnotatedTypeConfiguratorHolder configuratorHolder = annotatedTypeConfigurators.get(key);
+        if (configuratorHolder == null)
+        {
+            AnnotatedTypeConfigurator<T> configurator = getAnnotatedTypeConfigurator(clazz);
+            configuratorHolder = new AnnotatedTypeConfiguratorHolder(extension, id, configurator);
+            annotatedTypeConfigurators.put(key, configuratorHolder);
+        }
+
+        return configuratorHolder.getAnnotatedTypeConfigurator();
     }
 
     @Override
@@ -95,4 +108,15 @@ public class AfterTypeDiscoveryImpl exte
     {
         this.extension = instance;
     }
+
+    public Collection<AnnotatedTypeConfiguratorHolder> getAnnotatedTypeConfigurators()
+    {
+        return annotatedTypeConfigurators.values();
+    }
+
+    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