openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1441386 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/component/creation/
Date Fri, 01 Feb 2013 11:13:31 GMT
Author: arne
Date: Fri Feb  1 11:13:30 2013
New Revision: 1441386

URL: http://svn.apache.org/viewvc?rev=1441386&view=rev
Log:
OWB-770: Moved injection points from bean to producer

Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java?rev=1441386&r1=1441385&r2=1441386&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java
Fri Feb  1 11:13:30 2013
@@ -19,6 +19,7 @@
 package org.apache.webbeans.ejb.common.component;
 
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -77,10 +78,14 @@ public abstract class EjbBeanBuilder<T, 
     {
         E bean =  createBean(beanClass, webBeansContext.getWebBeansUtil().isBeanEnabled(annotatedType,
annotatedType.getJavaClass(), beanAttributes.getStereotypes()));
 
-        //X TODO hack to set the InjectionTarget
+        Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
+        for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
annotatedType))
+        {
+            injectionPoints.add(injectionPoint);
+        }
         InjectionTarget<T> injectionTarget = buildInjectionTarget(
                 bean.getAnnotatedType(),
-                bean.getInjectionPoints(),
+                injectionPoints,
                 webBeansContext,
                 Collections.<AnnotatedMethod<?>>emptyList(),
                 Collections.<AnnotatedMethod<?>>emptyList());
@@ -94,10 +99,6 @@ public abstract class EjbBeanBuilder<T, 
     public E getBean()
     {
         E bean = createBean(annotatedType.getJavaClass());
-        for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
annotatedType))
-        {
-            bean.addInjectionPoint(injectionPoint);
-        }
         EjbValidator.validateDecoratorOrInterceptor(bean.getReturnType());
         EjbValidator.validateEjbScopeType(bean);
         EjbValidator.validateGenericBeanType(bean.getReturnType(), bean.getScope());

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=1441386&r1=1441385&r2=1441386&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
Fri Feb  1 11:13:30 2013
@@ -20,12 +20,9 @@ package org.apache.webbeans.component;
 
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
+import java.util.Collections;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -68,9 +65,6 @@ public abstract class AbstractOwbBean<T>
     /**This bean is enabled or disabled*/
     protected boolean enabled = true;
 
-    /**Beans injection points*/
-    protected Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
-
     /** The producer */
     private Producer<T> producer;
 
@@ -282,21 +276,17 @@ public abstract class AbstractOwbBean<T>
     {
         return (Class<T>) getBeanClass();
     }
-
-    /**
-     * {@inheritDoc}
-     */    
-    public void addInjectionPoint(InjectionPoint injectionPoint)
-    {
-        injectionPoints.add(injectionPoint);
-    }
     
     /**
      * {@inheritDoc}
      */    
     public Set<InjectionPoint> getInjectionPoints()
     {
-        return injectionPoints;
+        if (producer == null)
+        {
+            return Collections.<InjectionPoint> emptySet();
+        }
+        return producer.getInjectionPoints();
     }
     
     /**
@@ -323,24 +313,6 @@ public abstract class AbstractOwbBean<T>
         return specializedBean;
     }
     
-    /**
-     * {@inheritDoc}
-     */    
-    public List<InjectionPoint> getInjectionPoint(Member member)
-    {
-        List<InjectionPoint> points = new ArrayList<InjectionPoint>();
-        
-        for(InjectionPoint ip : injectionPoints)
-        {
-            if(ip.getMember().equals(member))
-            {
-                points.add(ip);
-            }
-        }
-        
-        return points;
-    }
-    
      /**
      * {@inheritDoc}
      */    

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java?rev=1441386&r1=1441385&r2=1441386&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java
Fri Feb  1 11:13:30 2013
@@ -18,11 +18,7 @@
  */
 package org.apache.webbeans.component;
 
-import java.lang.reflect.Member;
-import java.util.List;
-
 import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Producer;
 
 import org.apache.webbeans.config.WebBeansContext;
@@ -58,24 +54,6 @@ public interface OwbBean<T> extends Bean
     public WebBeansType getWebBeansType();
     
     /**
-     * Adds new injection point.
-     * 
-     * @param injectionPoint injection point
-     */
-    public void addInjectionPoint(InjectionPoint injectionPoint);
-    
-    /**
-     * Gets injection points for given member.
-     * <p>
-     * For example, if member is field, it gets all
-     * injected field's injection points of bean.
-     * </p>
-     * @param member java member
-     * @return injection points for given member
-     */
-    public List<InjectionPoint> getInjectionPoint(Member member);
-
-    /**
      * Returns bean class type
      * @return bean class type
      */

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=1441386&r1=1441385&r2=1441386&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
Fri Feb  1 11:13:30 2013
@@ -296,13 +296,13 @@ public class DecoratorBeanBuilder<T>
     {
         DecoratorBean<T> decorator = new DecoratorBean<T>(webBeansContext, WebBeansType.MANAGED,
annotatedType, beanAttributes, annotatedType.getJavaClass());
         decorator.setEnabled(webBeansContext.getDecoratorsManager().isDecoratorEnabled(annotatedType.getJavaClass()));
-        InjectionTarget<T> injectionTarget
-                = buildInjectionTarget(annotatedType, decorator.getInjectionPoints(), webBeansContext,
getPostConstructMethods(), getPreDestroyMethods());
-        decorator.setProducer(injectionTarget);
+        Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
         for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(decorator,
annotatedType))
         {
-            decorator.addInjectionPoint(injectionPoint);
+            injectionPoints.add(injectionPoint);
         }
+        InjectionTarget<T> injectionTarget = buildInjectionTarget(annotatedType, injectionPoints,
webBeansContext, getPostConstructMethods(), getPreDestroyMethods());
+        decorator.setProducer(injectionTarget);
 
         // we can only do this after the bean injection points got scanned
         defineDelegate(decorator.getInjectionPoints());

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java?rev=1441386&r1=1441385&r2=1441386&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
Fri Feb  1 11:13:30 2013
@@ -37,6 +37,7 @@ import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -331,19 +332,18 @@ public abstract class InterceptorBeanBui
     public B getBean()
     {
         B bean = createBean(annotatedType.getJavaClass(), isInterceptorEnabled(), interceptionMethods);
-
-        //X TODO hack to set the InjectionTarget
+        Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
+        for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
annotatedType))
+        {
+            injectionPoints.add(injectionPoint);
+        }
         InjectionTarget<T> injectionTarget = new InjectionTargetImpl<T>(
                 bean.getAnnotatedType(),
-                bean.getInjectionPoints(),
+                injectionPoints,
                 webBeansContext,
                 Collections.<AnnotatedMethod<?>>emptyList(),
                 Collections.<AnnotatedMethod<?>>emptyList());
         bean.setProducer(injectionTarget);
-        for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
annotatedType))
-        {
-            bean.addInjectionPoint(injectionPoint);
-        }
         return bean;
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java?rev=1441386&r1=1441385&r2=1441386&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
Fri Feb  1 11:13:30 2013
@@ -18,7 +18,9 @@
  */
 package org.apache.webbeans.component.creation;
 
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -69,13 +71,13 @@ public class ManagedBeanBuilder<T, M ext
     {
         M bean = (M)new ManagedBean<T>(webBeansContext, WebBeansType.MANAGED, annotatedType,
beanAttributes, annotatedType.getJavaClass());
         bean.setEnabled(webBeansContext.getWebBeansUtil().isBeanEnabled(annotatedType, annotatedType.getJavaClass(),
beanAttributes.getStereotypes()));
+        Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
         for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean,
annotatedType))
         {
-            bean.addInjectionPoint(injectionPoint);
+            injectionPoints.add(injectionPoint);
         }
-        
         InjectionTarget<T> injectionTarget
-            = new InjectionTargetImpl<T>(bean.getAnnotatedType(), bean.getInjectionPoints(),
webBeansContext, getPostConstructMethods(), getPreDestroyMethods());
+            = new InjectionTargetImpl<T>(bean.getAnnotatedType(), injectionPoints,
webBeansContext, getPostConstructMethods(), getPreDestroyMethods());
         bean.setProducer(injectionTarget);
         webBeansContext.getWebBeansUtil().checkManagedBeanCondition(annotatedType);
         WebBeansUtil.checkGenericType(annotatedType.getJavaClass(), beanAttributes.getScope());

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java?rev=1441386&r1=1441385&r2=1441386&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
Fri Feb  1 11:13:30 2013
@@ -67,18 +67,6 @@ public class ProducerMethodBeanBuilder<T
                                                      + " found in super class : " + annotatedMethod.getDeclaringType().getJavaClass().getSuperclass().getName()
                                                      + " is not annotated with @Produces"
+ " for annotated method : " + annotatedMethod);
         }
-
-        /* To avoid multiple invocations of setBeanName(), following code is delayed to
-         * configSpecializedProducerMethodBeans() when checkSpecializations.
-        Annotation[] anns = AnnotationUtil.getQualifierAnnotations(superMethod.getAnnotations());
-
-        for (Annotation ann : anns)
-        {
-            bean.addQualifier(ann);
-        }
-        
-        WebBeansUtil.configuredProducerSpecializedName(bean, annotatedMethod.getJavaMember(),
superMethod);
-        */
         
         bean.setSpecializedBean(true);        
     }



Mime
View raw message