You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by rm...@apache.org on 2014/12/22 19:56:10 UTC

svn commit: r1647374 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/creation/DecoratorBeanBuilder.java container/BeanManagerImpl.java event/EventUtil.java inject/impl/InjectionPointFactory.java util/WebBeansUtil.java

Author: rmannibucau
Date: Mon Dec 22 18:56:10 2014
New Revision: 1647374

URL: http://svn.apache.org/r1647374
Log:
using injectionPoint.isDelegate instead of half reflection

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java?rev=1647374&r1=1647373&r2=1647374&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java Mon Dec 22 18:56:10 2014
@@ -20,7 +20,6 @@ package org.apache.webbeans.component.cr
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
-import javax.decorator.Delegate;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Alternative;
 import javax.enterprise.inject.spi.AnnotatedMethod;
@@ -167,11 +166,11 @@ public class DecoratorBeanBuilder<T> ext
     {
         boolean found = false;
         InjectionPoint ipFound = null;
-        for(InjectionPoint ip : injectionPoints)
+        for (InjectionPoint ip : injectionPoints)
         {
-            if(ip.getAnnotated().isAnnotationPresent(Delegate.class))
+            if (ip.isDelegate())
             {
-                if(!found)
+                if (!found)
                 {
                     found = true;
                     ipFound = ip;
@@ -188,7 +187,7 @@ public class DecoratorBeanBuilder<T> ext
         if(ipFound == null)
         {
             throw new WebBeansConfigurationException("Decorators must have a one @Delegate injection point." +
-                    "But the decorator bean : " + toString() + " has none");
+                        "But the decorator bean : " + toString() + " has none");
         }
 
         if(!(ipFound.getMember() instanceof Constructor))
@@ -196,7 +195,7 @@ public class DecoratorBeanBuilder<T> ext
             AnnotatedElement element = (AnnotatedElement)ipFound.getMember();
             if(!element.isAnnotationPresent(Inject.class))
             {
-                String message = "Error in decorator : "+ toString() + ". The delegate injection point must be an injected field, " +
+                String message = "Error in decorator : " + annotatedType + ". The delegate injection point must be an injected field, " +
                         "initializer method parameter or bean constructor method parameter.";
 
                 throw new WebBeansConfigurationException(message);

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=1647374&r1=1647373&r2=1647374&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 Mon Dec 22 18:56:10 2014
@@ -86,6 +86,7 @@ import org.apache.webbeans.portable.Anno
 import org.apache.webbeans.portable.InjectionTargetImpl;
 import org.apache.webbeans.portable.LazyInterceptorDefinedInjectionTarget;
 import org.apache.webbeans.portable.events.discovery.ErrorStack;
+import org.apache.webbeans.portable.events.generics.GProcessInjectionPoint;
 import org.apache.webbeans.portable.events.generics.GProcessInjectionTarget;
 import org.apache.webbeans.spi.adaptor.ELAdaptor;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
@@ -786,7 +787,7 @@ public class BeanManagerImpl implements
 
     public InjectionPoint createInjectionPoint(AnnotatedParameter<?> parameter)
     {
-        final InjectionPoint injectionPoint = webBeansContext.getInjectionPointFactory().buildInjectionPoint(null, parameter);
+        InjectionPoint injectionPoint = webBeansContext.getInjectionPointFactory().buildInjectionPoint(null, parameter, false);
         if (AnnotatedMethod.class.isInstance(parameter.getDeclaringCallable()))
         {
             try
@@ -798,6 +799,9 @@ public class BeanManagerImpl implements
                 throw new IllegalArgumentException(e);
             }
         } // TODO else constructor rules are a bit different
+        final GProcessInjectionPoint event = webBeansContext.getWebBeansUtil().fireProcessInjectionPointEvent(injectionPoint);
+        injectionPoint = event.getInjectionPoint();
+        event.setStarted();
         return injectionPoint;
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java?rev=1647374&r1=1647373&r2=1647374&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventUtil.java Mon Dec 22 18:56:10 2014
@@ -73,6 +73,10 @@ public final class EventUtil
             ParameterizedType pt = (ParameterizedType)type;
             candidateClazz = (Class<?>)pt.getRawType();
         }
+        else
+        {
+            throw new IllegalArgumentException("Can't determine the type for " + type);
+        }
         
         if(!candidateClazz.equals(Event.class))
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java?rev=1647374&r1=1647373&r2=1647374&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java Mon Dec 22 18:56:10 2014
@@ -148,12 +148,20 @@ public class InjectionPointFactory
         return buildInjectionPoint(owner, annotField, true);
     }
 
-    public <X> InjectionPoint buildInjectionPoint(Bean<?> owner, AnnotatedParameter<X> parameter)
+    public <X> InjectionPoint buildInjectionPoint(Bean<?> owner, AnnotatedParameter<X> parameter, boolean fireEvent)
     {
         Asserts.assertNotNull(parameter, "parameter parameter can not be null");
         Set<Annotation> anns = parameter.getAnnotations();
         Annotation[] qualifierAnnots = webBeansContext.getAnnotationManager().getQualifierAnnotations(anns.toArray(new Annotation[anns.size()]));
-        return new InjectionPointImpl(owner, Arrays.asList(qualifierAnnots), parameter);
+        InjectionPointImpl injectionPoint = new InjectionPointImpl(owner, Arrays.asList(qualifierAnnots), parameter);
+        if (fireEvent)
+        {
+            GProcessInjectionPoint event = webBeansContext.getWebBeansUtil().fireProcessInjectionPointEvent(injectionPoint);
+            InjectionPoint ip = event.getInjectionPoint();
+            event.setStarted();
+            return ip;
+        }
+        return injectionPoint;
     }
 
     public <X> List<InjectionPoint> buildInjectionPoints(Bean<?> owner, AnnotatedCallable<X> callable)
@@ -174,7 +182,7 @@ public class InjectionPointFactory
             //@Observes is not injection point type for method parameters
             if (parameter.getAnnotation(Observes.class) == null)
             {
-                lists.add(buildInjectionPoint(owner, parameter));
+                lists.add(buildInjectionPoint(owner, parameter, true));
             }
         }
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1647374&r1=1647373&r2=1647374&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Mon Dec 22 18:56:10 2014
@@ -851,7 +851,7 @@ public final class WebBeansUtil
 
         Class<?> candidateClazz = ClassUtil.getClass(type);
 
-        if(!candidateClazz.isAssignableFrom(Instance.class))
+        if (!candidateClazz.isAssignableFrom(Instance.class) || Object.class == candidateClazz)
         {
             return false;
         }