You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ar...@apache.org on 2013/01/06 10:50:45 UTC

svn commit: r1429486 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/ webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-imp...

Author: arne
Date: Sun Jan  6 09:50:45 2013
New Revision: 1429486

URL: http://svn.apache.org/viewvc?rev=1429486&view=rev
Log:
OWB-745: Created ProducerMethodBeanCreator and ProducerFieldBeanCreator

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanCreator.java
Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanCreatorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreatorImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanCreatorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanCreatorImpl.java?rev=1429486&r1=1429485&r2=1429486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanCreatorImpl.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanCreatorImpl.java Sun Jan  6 09:50:45 2013
@@ -68,7 +68,7 @@ public class EjbBeanCreatorImpl<T> exten
     @Override
     public void defineApiType()
     {
-        Set<Type> types = getAnnotatedType().getTypeClosure();
+        Set<Type> types = getAnnotated().getTypeClosure();
         getBean().getTypes().addAll(types);
     }
     

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java?rev=1429486&r1=1429485&r2=1429486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanCreator.java Sun Jan  6 09:50:45 2013
@@ -20,14 +20,16 @@ package org.apache.webbeans.component.cr
 
 import java.lang.reflect.Type;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
-import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.InjectionPoint;
 
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.config.DefinitionUtil;
 import org.apache.webbeans.util.AnnotationUtil;
-import org.apache.webbeans.util.WebBeansUtil;
 
 /**
  * Abstract implementation.
@@ -41,11 +43,7 @@ public class AbstractBeanCreator<T> impl
     /**Bean instance*/
     private final AbstractOwbBean<T> bean;    
     
-    /**
-     * If annotated type is set by ProcessAnnotatedType event, used this annotated type
-     * to define bean instance instead of using class artifacts.
-     */
-    private AnnotatedType<T> annotatedType;
+    private Annotated annotated;
 
     private final DefinitionUtil definitionUtil;
     
@@ -55,10 +53,10 @@ public class AbstractBeanCreator<T> impl
      * @param bean bean instance
      * @param beanAnnotations annotations
      */
-    public AbstractBeanCreator(AbstractOwbBean<T> bean, AnnotatedType<T> annotatedType)
+    public AbstractBeanCreator(AbstractOwbBean<T> bean, Annotated annotated)
     {
         this.bean = bean;
-        this.annotatedType = annotatedType;
+        this.annotated = annotated;
         definitionUtil = bean.getWebBeansContext().getDefinitionUtil();
     }
 
@@ -75,7 +73,7 @@ public class AbstractBeanCreator<T> impl
      */
     public void defineApiType()
     {
-        Set<Type> types = annotatedType.getTypeClosure();
+        Set<Type> types = annotated.getTypeClosure();
         bean.getTypes().addAll(types);
         Set<String> ignored = bean.getWebBeansContext().getOpenWebBeansConfiguration().getIgnoredInterfaces();
         for (Iterator<Type> i = bean.getTypes().iterator(); i.hasNext();)
@@ -93,16 +91,7 @@ public class AbstractBeanCreator<T> impl
      */
     public void defineQualifier()
     {
-        definitionUtil.defineQualifiers(bean, AnnotationUtil.getAnnotationsFromSet(annotatedType.getAnnotations()));
-    }
-    
-    /**
-     * {@inheritDoc}
-     */
-    public void defineName(String defaultName)
-    {
-        definitionUtil.defineName(bean, AnnotationUtil.getAnnotationsFromSet(annotatedType.getAnnotations()),
-                    WebBeansUtil.getManagedBeanDefaultName(annotatedType.getJavaClass().getSimpleName()));
+        definitionUtil.defineQualifiers(bean, AnnotationUtil.getAnnotationsFromSet(annotated.getAnnotations()));
     }
 
     /**
@@ -110,7 +99,7 @@ public class AbstractBeanCreator<T> impl
      */
     public void defineScopeType(String errorMessage, boolean allowLazyInit)
     {
-        definitionUtil.defineScopeType(bean, AnnotationUtil.getAnnotationsFromSet(annotatedType.getAnnotations()), errorMessage, false);
+        definitionUtil.defineScopeType(bean, AnnotationUtil.getAnnotationsFromSet(annotated.getAnnotations()), errorMessage, false);
     }
 
     /**
@@ -126,7 +115,17 @@ public class AbstractBeanCreator<T> impl
      */
     public void defineStereoTypes()
     {
-        definitionUtil.defineStereoTypes(bean, AnnotationUtil.getAnnotationsFromSet(annotatedType.getAnnotations()));
+        definitionUtil.defineStereoTypes(bean, AnnotationUtil.getAnnotationsFromSet(annotated.getAnnotations()));
+    }
+    
+    protected <X> void addMethodInjectionPointMetaData(AnnotatedMethod<X> method)
+    {
+        List<InjectionPoint> injectionPoints = getBean().getWebBeansContext().getInjectionPointFactory().getMethodInjectionPointData(getBean(), method);
+        for (InjectionPoint injectionPoint : injectionPoints)
+        {
+            getBean().getWebBeansContext().getDefinitionUtil().addImplicitComponentForInjectionPoint(injectionPoint);
+            getBean().addInjectionPoint(injectionPoint);
+        }
     }
 
     /**
@@ -137,8 +136,8 @@ public class AbstractBeanCreator<T> impl
         return bean;
     }
 
-    protected AnnotatedType<T> getAnnotatedType()
+    protected Annotated getAnnotated()
     {
-        return annotatedType;
+        return annotated;
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java?rev=1429486&r1=1429485&r2=1429486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjecionTargetBeanCreator.java Sun Jan  6 09:50:45 2013
@@ -39,7 +39,9 @@ import javax.enterprise.inject.Specializ
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -82,15 +84,23 @@ public abstract class AbstractInjecionTa
         super(bean, bean.getAnnotatedType());
         webBeansContext = bean.getWebBeansContext();
     }
-    
- 
+        
+    /**
+     * {@inheritDoc}
+     */
+    public void defineName(String defaultName)
+    {
+        webBeansContext.getDefinitionUtil().defineName(getBean(), AnnotationUtil.getAnnotationsFromSet(getAnnotated().getAnnotations()),
+                    WebBeansUtil.getManagedBeanDefaultName(getAnnotated().getJavaClass().getSimpleName()));
+    }
+
     /**
      * {@inheritDoc}
      */
     public void defineDisposalMethods()
     {
         final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
-        Set<AnnotatedMethod<? super T>> annotatedMethods = getAnnotatedType().getMethods();    
+        Set<AnnotatedMethod<? super T>> annotatedMethods = getAnnotated().getMethods();    
         ProducerMethodBean<?> previous = null;
         for (AnnotatedMethod<? super T> annotatedMethod : annotatedMethods)
         {
@@ -155,7 +165,7 @@ public abstract class AbstractInjecionTa
                 
                 pr.setDisposalMethod(declaredMethod);
 
-                webBeansContext.getAnnotatedTypeUtil().addMethodInjectionPointMetaData(getBean(), annotatedMethod);
+                addMethodInjectionPointMetaData(annotatedMethod);
                 
             }
         }
@@ -168,7 +178,7 @@ public abstract class AbstractInjecionTa
     {
         AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
 
-        Set<AnnotatedField<? super T>> annotatedFields = getAnnotatedType().getFields();   
+        Set<AnnotatedField<? super T>> annotatedFields = getAnnotated().getFields();   
         for(AnnotatedField<? super T> annotatedField: annotatedFields)
         {
             if(Modifier.isPublic(annotatedField.getJavaMember().getModifiers()) && !annotatedField.isStatic())
@@ -215,7 +225,7 @@ public abstract class AbstractInjecionTa
                 if (!Modifier.isStatic(mod) && !Modifier.isFinal(mod))
                 {
                     getBean().addInjectedField(field);
-                    webBeansContext.getAnnotatedTypeUtil().addFieldInjectionPointMetaData(getBean(), annotatedField);                                
+                    addFieldInjectionPointMetaData(annotatedField);                                
                 }
             }                                    
         }
@@ -226,7 +236,7 @@ public abstract class AbstractInjecionTa
      */
     public void defineInjectedMethods()
     {
-        Set<AnnotatedMethod<? super T>> annotatedMethods = getAnnotatedType().getMethods();
+        Set<AnnotatedMethod<? super T>> annotatedMethods = getAnnotated().getMethods();
         
         for (AnnotatedMethod<? super T> annotatedMethod : annotatedMethods)
         {            
@@ -252,7 +262,7 @@ public abstract class AbstractInjecionTa
             if (!Modifier.isStatic(method.getModifiers()))
             {
                 getBean().addInjectedMethod(method);
-                webBeansContext.getAnnotatedTypeUtil().addMethodInjectionPointMetaData(getBean(), annotatedMethod);
+                addMethodInjectionPointMetaData(annotatedMethod);
             }
         }
     }
@@ -263,7 +273,7 @@ public abstract class AbstractInjecionTa
     public Set<ObserverMethod<?>> defineObserverMethods()
     {   
         Set<ObserverMethod<?>> definedObservers = new HashSet<ObserverMethod<?>>();
-        Set<AnnotatedMethod<? super T>> annotatedMethods = getAnnotatedType().getMethods();    
+        Set<AnnotatedMethod<? super T>> annotatedMethods = getAnnotated().getMethods();    
         for (AnnotatedMethod<? super T> annotatedMethod : annotatedMethods)
         {
             AnnotatedMethod<T> annt = (AnnotatedMethod<T>)annotatedMethod;
@@ -298,7 +308,7 @@ public abstract class AbstractInjecionTa
                 getBean().addObservableMethod(annotatedMethod.getJavaMember());
 
                 //Add injection point data
-                webBeansContext.getAnnotatedTypeUtil().addMethodInjectionPointMetaData(getBean(), annotatedMethod);
+                addMethodInjectionPointMetaData(annotatedMethod);
                 
                 //Looking for ObserverMethod
                 ObserverMethod<?> definedObserver = webBeansContext.getBeanManagerImpl().getNotificationManager().getObservableMethodForAnnotatedMethod(annotatedMethod, getBean());
@@ -319,10 +329,10 @@ public abstract class AbstractInjecionTa
     {
         DefinitionUtil definitionUtil = webBeansContext.getDefinitionUtil();
         Set<ProducerFieldBean<?>> producerBeans = new HashSet<ProducerFieldBean<?>>();
-        Set<AnnotatedField<? super T>> annotatedFields = getAnnotatedType().getFields();        
+        Set<AnnotatedField<? super T>> annotatedFields = getAnnotated().getFields();        
         for(AnnotatedField<? super T> annotatedField: annotatedFields)
         {
-            if(annotatedField.isAnnotationPresent(Produces.class) && annotatedField.getDeclaringType().equals(getAnnotatedType()))
+            if(annotatedField.isAnnotationPresent(Produces.class) && annotatedField.getDeclaringType().equals(getAnnotated()))
             {
                 Type genericType = annotatedField.getBaseType();
                 
@@ -414,11 +424,11 @@ public abstract class AbstractInjecionTa
     {
         DefinitionUtil definitionUtil = webBeansContext.getDefinitionUtil();
         Set<ProducerMethodBean<?>> producerBeans = new HashSet<ProducerMethodBean<?>>();
-        Set<AnnotatedMethod<? super T>> annotatedMethods = getAnnotatedType().getMethods();
+        Set<AnnotatedMethod<? super T>> annotatedMethods = getAnnotated().getMethods();
         
         for(AnnotatedMethod<? super T> annotatedMethod: annotatedMethods)
         {
-            if(annotatedMethod.isAnnotationPresent(Produces.class) && annotatedMethod.getDeclaringType().equals(getAnnotatedType()))
+            if(annotatedMethod.isAnnotationPresent(Produces.class) && annotatedMethod.getDeclaringType().equals(getAnnotated()))
             {
                 WebBeansAnnotatedTypeUtil.checkProducerMethodForDeployment(annotatedMethod);
                 boolean specialize = false;
@@ -432,7 +442,8 @@ public abstract class AbstractInjecionTa
                     specialize = true;
                 }
                 
-                ProducerMethodBean<T> producerMethodBean = new ProducerMethodBean<T>(getBean(), (Class<T>)ClassUtil.getClass(annotatedMethod.getBaseType()));
+                ProducerMethodBeanCreator<T> producerMethodBeanCreator = new ProducerMethodBeanCreator<T>(getBean(), annotatedMethod);
+                ProducerMethodBean<T> producerMethodBean = producerMethodBeanCreator.getBean();
                 producerMethodBean.setCreatorMethod(annotatedMethod.getJavaMember());
                 
                 if(specialize)
@@ -473,7 +484,7 @@ public abstract class AbstractInjecionTa
                                                                                WebBeansUtil.getProducerDefaultName(annotatedMethod.getJavaMember().getName()));
                 definitionUtil.defineQualifiers(producerMethodBean, AnnotationUtil.getAnnotationsFromSet(annotatedMethod.getAnnotations()));
                 
-                webBeansContext.getAnnotatedTypeUtil().addMethodInjectionPointMetaData(producerMethodBean, annotatedMethod);
+                producerMethodBeanCreator.addMethodInjectionPointMetaData(annotatedMethod);
                 producerBeans.add(producerMethodBean);
                 
             }
@@ -483,6 +494,16 @@ public abstract class AbstractInjecionTa
         return producerBeans;
     }
     
+    private <X> void addFieldInjectionPointMetaData(AnnotatedField<X> annotField)
+    {
+        InjectionPoint injectionPoint = webBeansContext.getInjectionPointFactory().getFieldInjectionPointData(getBean(), annotField);
+        if (injectionPoint != null)
+        {
+            webBeansContext.getDefinitionUtil().addImplicitComponentForInjectionPoint(injectionPoint);
+            getBean().addInjectionPoint(injectionPoint);
+        }
+    }
+
     /**
      * Return type-safe bean instance.
      */
@@ -490,4 +511,9 @@ public abstract class AbstractInjecionTa
     {
         return (AbstractInjectionTargetBean<T>)super.getBean();
     }
+
+    protected AnnotatedType<T> getAnnotated()
+    {
+        return (AnnotatedType<T>) super.getAnnotated();
+    }
 }

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanCreator.java?rev=1429486&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanCreator.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanCreator.java Sun Jan  6 09:50:45 2013
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.component.creation;
+
+import javax.enterprise.inject.spi.Annotated;
+
+import org.apache.webbeans.component.AbstractProducerBean;
+
+public class AbstractProducerBeanCreator<T> extends AbstractBeanCreator<T>
+{
+
+    public AbstractProducerBeanCreator(AbstractProducerBean<T> bean, Annotated annotated)
+    {
+        super(bean, annotated);
+    }
+
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java?rev=1429486&r1=1429485&r2=1429486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanCreatorImpl.java Sun Jan  6 09:50:45 2013
@@ -18,17 +18,14 @@
  */
 package org.apache.webbeans.component.creation;
 
-import java.lang.reflect.Constructor;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javax.enterprise.inject.spi.AnnotatedConstructor;
 import javax.enterprise.inject.spi.AnnotatedType;
 
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
-import org.apache.webbeans.util.WebBeansAnnotatedTypeUtil;
 
 public class AnnotatedTypeBeanCreatorImpl<T> extends ManagedBeanCreatorImpl<T>
 {
@@ -45,22 +42,14 @@ public class AnnotatedTypeBeanCreatorImp
     @Override
     public void defineConstructor()
     {
-        Constructor<T> constructor;
         try
         {
-            WebBeansAnnotatedTypeUtil annotatedTypeUtil = getBean().getWebBeansContext().getAnnotatedTypeUtil();
-            AnnotatedConstructor<T> annotated = annotatedTypeUtil.getBeanConstructor(getAnnotatedType());
-            constructor = annotated.getJavaMember();
-            annotatedTypeUtil.addConstructorInjectionPointMetaData(getBean(), annotated);
-            
-            getBean().setConstructor(constructor);
-            
+            addConstructorInjectionPointMetaData();
         }
         catch(Exception e)
         {
             // if no constructor could be found, we just leave the empty set.
-            logger.log(Level.INFO, OWBLogConst.WARN_0012, getAnnotatedType().getJavaClass());
+            logger.log(Level.INFO, OWBLogConst.WARN_0012, getAnnotated().getJavaClass());
         }
     }
-    
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java?rev=1429486&r1=1429485&r2=1429486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanCreator.java Sun Jan  6 09:50:45 2013
@@ -69,13 +69,6 @@ public interface BeanCreator<T>
     public void defineQualifier();
     
     /**
-     * Defines bean name.
-     * 
-     * @param defaultName default bean name
-     */
-    public void defineName(String defaultName);   
-    
-    /**
      * Gets bean.
      * 
      * @return bean instance

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreatorImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreatorImpl.java?rev=1429486&r1=1429485&r2=1429486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreatorImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanCreatorImpl.java Sun Jan  6 09:50:45 2013
@@ -19,20 +19,25 @@
 package org.apache.webbeans.component.creation;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.spi.AnnotatedConstructor;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.ProcessInjectionTarget;
 import javax.enterprise.inject.spi.Producer;
+import javax.inject.Inject;
 
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.ProducerFieldBean;
@@ -43,12 +48,14 @@ import org.apache.webbeans.container.Bea
 import org.apache.webbeans.decorator.DecoratorUtil;
 import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
 import org.apache.webbeans.event.ObserverMethodImpl;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.inject.DeploymentException;
+import org.apache.webbeans.inject.impl.InjectionPointFactory;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.portable.events.ProcessBeanImpl;
 import org.apache.webbeans.portable.events.ProcessProducerImpl;
 import org.apache.webbeans.portable.events.generics.GProcessManagedBean;
-import org.apache.webbeans.util.WebBeansAnnotatedTypeUtil;
+import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -82,7 +89,7 @@ public class ManagedBeanCreatorImpl<T> e
     @Override
     public void checkCreateConditions()
     {
-        webBeansContext.getWebBeansUtil().checkManagedBeanCondition(getAnnotatedType());
+        webBeansContext.getWebBeansUtil().checkManagedBeanCondition(getAnnotated());
         WebBeansUtil.checkGenericType(getBean());
         //Check Unproxiable
         webBeansContext.getWebBeansUtil().checkUnproxiableApiType(getBean(), getBean().getScope());
@@ -94,10 +101,7 @@ public class ManagedBeanCreatorImpl<T> e
      */
     public void defineConstructor()
     {
-        AnnotatedConstructor<T> annotated = WebBeansAnnotatedTypeUtil.getBeanConstructor(getAnnotatedType());
-        Constructor<T> constructor = annotated.getJavaMember();
-        webBeansContext.getAnnotatedTypeUtil().addConstructorInjectionPointMetaData(getBean(), annotated);
-        getBean().setConstructor(constructor);
+        addConstructorInjectionPointMetaData();
     }
 
     /**
@@ -299,6 +303,81 @@ public class ManagedBeanCreatorImpl<T> e
         }
 
     }
+    
+    protected AnnotatedConstructor<T> getBeanConstructor()
+    {
+        Asserts.assertNotNull(getAnnotated(),"Type is null");
+        AnnotatedConstructor<T> result = null;
+        
+        Set<AnnotatedConstructor<T>> annConsts = getAnnotated().getConstructors();
+        if(annConsts != null)
+        {
+            boolean found = false;
+            boolean noParamConsIsDefined = false;
+            for(AnnotatedConstructor<T> annConst : annConsts)
+            {
+                if(annConst.isAnnotationPresent(Inject.class))
+                {
+                    if (found)
+                    {
+                        throw new WebBeansConfigurationException("There are more than one constructor with @Inject annotation in annotation type : "
+                                                                 + getAnnotated());
+                    }
+                    
+                    found = true;
+                    result = annConst;
+                }
+                else
+                {
+                    if(!found && !noParamConsIsDefined)
+                    {
+                        List<AnnotatedParameter<T>> parameters = annConst.getParameters();
+                        if(parameters != null && parameters.isEmpty())
+                        {
+                            result = annConst;
+                            noParamConsIsDefined = true;
+                        }                        
+                    }
+                }
+            }
+        }
+        
+        if (result == null)
+        {
+            throw new WebBeansConfigurationException("No constructor is found for the annotated type : " + getAnnotated());
+        }
+        
+        List<AnnotatedParameter<T>> parameters = result.getParameters();
+        for(AnnotatedParameter<T> parameter : parameters)
+        {
+            if (parameter.isAnnotationPresent(Disposes.class))
+            {
+                throw new WebBeansConfigurationException("Constructor parameter annotations can not contain @Disposes annotation in annotated constructor : "
+                                                         + result);
+            }
+            
+            if(parameter.isAnnotationPresent(Observes.class))
+            {
+                throw new WebBeansConfigurationException("Constructor parameter annotations can not contain @Observes annotation in annotated constructor : " + result);
+            }
+            
+        }
+
+        return result;
+    }
+    
+    protected void addConstructorInjectionPointMetaData()
+    {
+        InjectionPointFactory injectionPointFactory = webBeansContext.getInjectionPointFactory();
+        AnnotatedConstructor<T> beanConstructor = getBeanConstructor();
+        List<InjectionPoint> injectionPoints = injectionPointFactory.getConstructorInjectionPointData(getBean(), beanConstructor);
+        for (InjectionPoint injectionPoint : injectionPoints)
+        {
+            webBeansContext.getDefinitionUtil().addImplicitComponentForInjectionPoint(injectionPoint);
+            getBean().addInjectionPoint(injectionPoint);
+        }
+        getBean().setConstructor(beanConstructor.getJavaMember());
+    }
 
     /**
      * Define decorator bean.

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanCreator.java?rev=1429486&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanCreator.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanCreator.java Sun Jan  6 09:50:45 2013
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.component.creation;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.apache.webbeans.component.ProducerFieldBean;
+
+public class ProducerFieldBeanCreator<T> extends AbstractProducerBeanCreator<T>
+{
+
+    public ProducerFieldBeanCreator(ProducerFieldBean<T> bean, AnnotatedType<T> annotatedType)
+    {
+        super(bean, annotatedType);
+    }
+
+}

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanCreator.java?rev=1429486&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanCreator.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanCreator.java Sun Jan  6 09:50:45 2013
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.component.creation;
+
+import javax.enterprise.inject.spi.AnnotatedMethod;
+
+import org.apache.webbeans.component.InjectionTargetBean;
+import org.apache.webbeans.component.ProducerMethodBean;
+import org.apache.webbeans.util.ClassUtil;
+
+public class ProducerMethodBeanCreator<T> extends AbstractProducerBeanCreator<T>
+{
+
+    public ProducerMethodBeanCreator(InjectionTargetBean<T> parent, AnnotatedMethod<? super T> annotatedMethod)
+    {
+        super(new ProducerMethodBean<T>(parent, (Class<T>)ClassUtil.getClass(annotatedMethod.getBaseType())), annotatedMethod);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public ProducerMethodBean<T> getBean()
+    {
+        return (ProducerMethodBean<T>)super.getBean();
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java?rev=1429486&r1=1429485&r2=1429486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java Sun Jan  6 09:50:45 2013
@@ -87,7 +87,7 @@ public class WebBeansContext
     private final InjectionPointFactory injectionPointFactory = new InjectionPointFactory(this);
     private final InterceptorUtil interceptorUtil = new InterceptorUtil(this);
     private final DefinitionUtil definitionUtil = new DefinitionUtil(this);
-    private final WebBeansAnnotatedTypeUtil annotatedTypeUtil = new WebBeansAnnotatedTypeUtil(this);
+    private final WebBeansAnnotatedTypeUtil annotatedTypeUtil = new WebBeansAnnotatedTypeUtil();
     private final SecurityService securityService;
     private final LoaderService loaderService;
     private ScannerService scannerService;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=1429486&r1=1429485&r2=1429486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java Sun Jan  6 09:50:45 2013
@@ -21,129 +21,21 @@ package org.apache.webbeans.util;
 import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.component.AbstractInjectionTargetBean;
 import org.apache.webbeans.component.AbstractOwbBean;
-import org.apache.webbeans.component.OwbBean;
-import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.inject.impl.InjectionPointFactory;
 
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
 import java.lang.reflect.Method;
 import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
 
 public final class WebBeansAnnotatedTypeUtil
 {
-    private final WebBeansContext webBeansContext;
-
-    public WebBeansAnnotatedTypeUtil(WebBeansContext webBeansContext)
-    {
-        this.webBeansContext = webBeansContext;
-    }
-    
-    public static <T> AnnotatedConstructor<T> getBeanConstructor(AnnotatedType<T> type)
-    {
-        Asserts.assertNotNull(type,"Type is null");
-        AnnotatedConstructor<T> result = null;
-        
-        Set<AnnotatedConstructor<T>> annConsts = type.getConstructors();
-        if(annConsts != null)
-        {
-            boolean found = false;
-            boolean noParamConsIsDefined = false;
-            for(AnnotatedConstructor<T> annConst : annConsts)
-            {
-                if(annConst.isAnnotationPresent(Inject.class))
-                {
-                    if (found)
-                    {
-                        throw new WebBeansConfigurationException("There are more than one constructor with @Inject annotation in annotation type : "
-                                                                 + type);
-                    }
-                    
-                    found = true;
-                    result = annConst;
-                }
-                else
-                {
-                    if(!found && !noParamConsIsDefined)
-                    {
-                        List<AnnotatedParameter<T>> parameters = annConst.getParameters();
-                        if(parameters != null && parameters.isEmpty())
-                        {
-                            result = annConst;
-                            noParamConsIsDefined = true;
-                        }                        
-                    }
-                }
-            }
-        }
-        
-        if (result == null)
-        {
-            throw new WebBeansConfigurationException("No constructor is found for the annotated type : " + type);
-        }
-        
-        List<AnnotatedParameter<T>> parameters = result.getParameters();
-        for(AnnotatedParameter<T> parameter : parameters)
-        {
-            if (parameter.isAnnotationPresent(Disposes.class))
-            {
-                throw new WebBeansConfigurationException("Constructor parameter annotations can not contain @Disposes annotation in annotated constructor : "
-                                                         + result);
-            }
-            
-            if(parameter.isAnnotationPresent(Observes.class))
-            {
-                throw new WebBeansConfigurationException("Constructor parameter annotations can not contain @Observes annotation in annotated constructor : " + result);
-            }
-            
-        }
-
-        
-        return result;
-    }
-    
-    public <T> void addConstructorInjectionPointMetaData(AbstractOwbBean<T> owner, AnnotatedConstructor<T> constructor)
-    {
-        InjectionPointFactory injectionPointFactory = owner.getWebBeansContext().getInjectionPointFactory();
-        List<InjectionPoint> injectionPoints = injectionPointFactory.getConstructorInjectionPointData(owner, constructor);
-        for (InjectionPoint injectionPoint : injectionPoints)
-        {
-            webBeansContext.getDefinitionUtil().addImplicitComponentForInjectionPoint(injectionPoint);
-            owner.addInjectionPoint(injectionPoint);
-        }
-    }
-    
-    public <T,X> void addMethodInjectionPointMetaData(OwbBean<T> owner, AnnotatedMethod<X> method)
-    {
-        List<InjectionPoint> injectionPoints = owner.getWebBeansContext().getInjectionPointFactory().getMethodInjectionPointData(owner, method);
-        for (InjectionPoint injectionPoint : injectionPoints)
-        {
-            webBeansContext.getDefinitionUtil().addImplicitComponentForInjectionPoint(injectionPoint);
-            owner.addInjectionPoint(injectionPoint);
-        }
-    }
-    
-    public <T,X> void addFieldInjectionPointMetaData(AbstractOwbBean<T> owner, AnnotatedField<X> annotField)
-    {
-        InjectionPoint injectionPoint = owner.getWebBeansContext().getInjectionPointFactory().getFieldInjectionPointData(owner, annotField);
-        if (injectionPoint != null)
-        {
-            webBeansContext.getDefinitionUtil().addImplicitComponentForInjectionPoint(injectionPoint);
-            owner.addInjectionPoint(injectionPoint);
-        }
-    }
     
     /**
      * Check producer method is ok for deployment.
@@ -163,7 +55,6 @@ public final class WebBeansAnnotatedType
         }
     }
     
-    
     public static <X> void configureProducerSpecialization(AbstractOwbBean<X> bean,AnnotatedMethod<X> annotatedMethod)
     {
         List<AnnotatedParameter<X>> annotatedParameters = annotatedMethod.getParameters();