openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1798578 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: configurator/InjectionPointConfiguratorImpl.java inject/impl/InjectionPointImpl.java portable/events/ProcessInjectionPointImpl.java
Date Tue, 13 Jun 2017 11:33:14 GMT
Author: struberg
Date: Tue Jun 13 11:33:13 2017
New Revision: 1798578

URL: http://svn.apache.org/viewvc?rev=1798578&view=rev
Log:
OWB-1187 implement InjectionPointConfigurator

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/InjectionPointConfiguratorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/InjectionPointConfiguratorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/InjectionPointConfiguratorImpl.java?rev=1798578&r1=1798577&r2=1798578&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/InjectionPointConfiguratorImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/configurator/InjectionPointConfiguratorImpl.java
Tue Jun 13 11:33:13 2017
@@ -18,58 +18,120 @@
  */
 package org.apache.webbeans.configurator;
 
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.configurator.InjectionPointConfigurator;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
 import java.lang.reflect.Type;
+import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.webbeans.annotation.DefaultLiteral;
+import org.apache.webbeans.inject.impl.InjectionPointImpl;
+
 public class InjectionPointConfiguratorImpl implements InjectionPointConfigurator
 {
+
+    private Bean<?> ownerBean;
+    private Type type;
+    private Set<Annotation> qualifiers = new HashSet<>();
+    private Annotated annotated;
+    private Member member;
+    private boolean isDelegate;
+    private boolean isTransient;
+
+    public InjectionPointConfiguratorImpl(InjectionPoint originalInjectionPoint)
+    {
+        this.ownerBean = originalInjectionPoint.getBean();
+        this.type = originalInjectionPoint.getType();
+        this.qualifiers.addAll(originalInjectionPoint.getQualifiers());
+        this.annotated = originalInjectionPoint.getAnnotated();
+        this.member = originalInjectionPoint.getMember();
+        this.isDelegate = originalInjectionPoint.isDelegate();
+        this.isTransient = originalInjectionPoint.isTransient();
+    }
+
     @Override
     public InjectionPointConfigurator type(Type requiredType)
     {
-        throw new UnsupportedOperationException("TODO implement CDI 2.0");
+        this.type = requiredType;
+        return this;
     }
 
     @Override
     public InjectionPointConfigurator addQualifier(Annotation qualifier)
     {
-        throw new UnsupportedOperationException("TODO implement CDI 2.0");
+        this.qualifiers.add(qualifier);
+        return this;
     }
 
     @Override
     public InjectionPointConfigurator addQualifiers(Annotation... qualifiers)
     {
-        throw new UnsupportedOperationException("TODO implement CDI 2.0");
+        for (Annotation qualifier : qualifiers)
+        {
+            this.qualifiers.add(qualifier);
+        }
+        return this;
     }
 
     @Override
     public InjectionPointConfigurator addQualifiers(Set<Annotation> qualifiers)
     {
-        throw new UnsupportedOperationException("TODO implement CDI 2.0");
+        this.qualifiers.addAll(qualifiers);
+        return this;
     }
 
     @Override
     public InjectionPointConfigurator qualifiers(Annotation... qualifiers)
     {
-        throw new UnsupportedOperationException("TODO implement CDI 2.0");
+        this.qualifiers.clear();
+        addQualifiers(qualifiers);
+        return this;
     }
 
     @Override
     public InjectionPointConfigurator qualifiers(Set<Annotation> qualifiers)
     {
-        throw new UnsupportedOperationException("TODO implement CDI 2.0");
+        this.qualifiers.clear();
+        addQualifiers(qualifiers);
+        return this;
     }
 
     @Override
     public InjectionPointConfigurator delegate(boolean delegate)
     {
-        throw new UnsupportedOperationException("TODO implement CDI 2.0");
+        this.isDelegate = delegate;
+        return this;
     }
 
     @Override
     public InjectionPointConfigurator transientField(boolean trans)
     {
-        throw new UnsupportedOperationException("TODO implement CDI 2.0");
+        this.isTransient = trans;
+        return this;
+    }
+
+    public InjectionPoint getInjectionPoint()
+    {
+        // apply the rules from 3.8 '@Default qualifier'
+        if (qualifiers.isEmpty())
+        {
+            qualifiers.add(DefaultLiteral.INSTANCE);
+        }
+        else if (qualifiers.size() > 1)
+        {
+            qualifiers.remove(DefaultLiteral.INSTANCE);
+        }
+
+        return new InjectionPointImpl(ownerBean,
+                type,
+                qualifiers,
+                annotated,
+                member,
+                isDelegate,
+                isTransient);
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java?rev=1798578&r1=1798577&r2=1798578&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
Tue Jun 13 11:33:13 2017
@@ -55,7 +55,7 @@ import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.OwbCustomObjectInputStream;
 import org.apache.webbeans.util.WebBeansUtil;
 
-class InjectionPointImpl implements InjectionPoint, Serializable
+public class InjectionPointImpl implements InjectionPoint, Serializable
 {
     private static final long serialVersionUID = 1047233127758068484L;
 
@@ -72,7 +72,7 @@ class InjectionPointImpl implements Inje
     private boolean transientt;
     
     private boolean delegate;
-    
+
     InjectionPointImpl(Bean<?> ownerBean, Collection<Annotation> qualifiers,
AnnotatedField<?> annotatedField)
     {
         this(ownerBean, annotatedField.getBaseType(), qualifiers, annotatedField,
@@ -103,7 +103,7 @@ class InjectionPointImpl implements Inje
         this.transientt = false;
     }
     
-    private InjectionPointImpl(Bean<?> ownerBean, Type type, Collection<Annotation>
qualifiers, Annotated annotated, Member member, boolean delegate, boolean isTransient)
+    public InjectionPointImpl(Bean<?> ownerBean, Type type, Collection<Annotation>
qualifiers, Annotated annotated, Member member, boolean delegate, boolean isTransient)
     {
         if (type == null)
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java?rev=1798578&r1=1798577&r2=1798578&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java
Tue Jun 13 11:33:13 2017
@@ -19,6 +19,7 @@
 package org.apache.webbeans.portable.events;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.configurator.InjectionPointConfiguratorImpl;
 
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ProcessInjectionPoint;
@@ -35,6 +36,7 @@ public class ProcessInjectionPointImpl<T
 {
 
     private InjectionPoint injectionPoint;
+    private InjectionPointConfiguratorImpl injectionPointConfigurator;
 
 
     public ProcessInjectionPointImpl(InjectionPoint injectionPoint)
@@ -50,6 +52,10 @@ public class ProcessInjectionPointImpl<T
     public InjectionPoint getInjectionPoint()
     {
         checkState();
+        if (injectionPointConfigurator != null)
+        {
+            return injectionPointConfigurator.getInjectionPoint();
+        }
         return injectionPoint;
     }
 
@@ -61,6 +67,7 @@ public class ProcessInjectionPointImpl<T
     {
         checkState();
         this.injectionPoint = injectionPoint;
+        this.injectionPointConfigurator = null;
     }
 
     /**
@@ -73,10 +80,10 @@ public class ProcessInjectionPointImpl<T
         WebBeansContext.getInstance().getBeanManagerImpl().getErrorStack().pushError(t);
     }
 
-    //X TODO OWB-1182 CDI 2.0
     @Override
     public InjectionPointConfigurator configureInjectionPoint()
     {
-        throw new UnsupportedOperationException("CDI 2.0 not yet imlemented");
+        this.injectionPointConfigurator = new InjectionPointConfiguratorImpl(injectionPoint);
+        return injectionPointConfigurator;
     }
 }



Mime
View raw message