openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1465291 [1/2] - in /openwebbeans/trunk: webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/ webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/ webb...
Date Sat, 06 Apr 2013 19:04:28 GMT
Author: arne
Date: Sat Apr  6 19:04:24 2013
New Revision: 1465291

URL: http://svn.apache.org/r1465291
Log:
OWB-814: Implemented ProducerFactory and InjectionTargetFactory and use them

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionProducerFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SimpleProducerFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java
      - copied, changed from r1451507, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodProducerBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/DecoratorInjectionTargetFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionTargetFactoryImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InterceptorInjectionTargetFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ProducerFactory.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AbstractDecoratorInjectionTarget.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProviderBasedProxyProducerFactory.java
Removed:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodProducerBuilder.java
Modified:
    openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrincipalBean.java
    openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java
    openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java
    openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java
    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/AbstractProducerBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.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/ProducerFieldBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.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/ExtensionBeanBuilder.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/ObserverMethodsBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.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/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ExtensionProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerFieldProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/ProducerMethodProducer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/decorators/tests/ConversationDecoratorTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
    openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/component/JmsBean.java

Modified: openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrincipalBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrincipalBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrincipalBean.java (original)
+++ openwebbeans/trunk/webbeans-ee-common/src/main/java/org/apache/webbeans/ee/common/beans/PrincipalBean.java Sat Apr  6 19:04:24 2013
@@ -21,6 +21,7 @@ package org.apache.webbeans.ee.common.be
 import java.security.Principal;
 
 import org.apache.webbeans.component.BuildInOwbBean;
+import org.apache.webbeans.component.SimpleProducerFactory;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.portable.ProviderBasedProxyProducer;
@@ -30,8 +31,10 @@ public class PrincipalBean extends Build
 
     public PrincipalBean(WebBeansContext webBeansContext)
     {
-        super(webBeansContext, WebBeansType.PRINCIPAL, Principal.class);
-        setProducer(new ProviderBasedProxyProducer<Principal>(webBeansContext, Principal.class, new PrincipalProvider(webBeansContext)));
+        super(webBeansContext,
+              WebBeansType.PRINCIPAL,
+              Principal.class,
+              new SimpleProducerFactory<Principal>(new ProviderBasedProxyProducer<Principal>(webBeansContext, Principal.class, new PrincipalProvider(webBeansContext))));
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java (original)
+++ openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/UserTransactionBean.java Sat Apr  6 19:04:24 2013
@@ -21,6 +21,7 @@ package org.apache.webbeans.ee.beans;
 import javax.transaction.UserTransaction;
 
 import org.apache.webbeans.component.BuildInOwbBean;
+import org.apache.webbeans.component.SimpleProducerFactory;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.portable.ProviderBasedProxyProducer;
@@ -30,8 +31,11 @@ public class UserTransactionBean extends
 
     public UserTransactionBean(WebBeansContext webBeansContext)
     {
-        super(webBeansContext, WebBeansType.USERTRANSACTION, UserTransaction.class);
-        setProducer(new ProviderBasedProxyProducer<UserTransaction>(webBeansContext, UserTransaction.class, new UserTransactionProvider(webBeansContext)));
+        super(webBeansContext,
+              WebBeansType.USERTRANSACTION,
+              UserTransaction.class,
+              new SimpleProducerFactory<UserTransaction>(
+                      new ProviderBasedProxyProducer<UserTransaction>(webBeansContext, UserTransaction.class, new UserTransactionProvider(webBeansContext))));
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java (original)
+++ openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorBean.java Sat Apr  6 19:04:24 2013
@@ -21,6 +21,7 @@ package org.apache.webbeans.ee.beans;
 import javax.validation.Validator;
 
 import org.apache.webbeans.component.BuildInOwbBean;
+import org.apache.webbeans.component.SimpleProducerFactory;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.portable.ProviderBasedProxyProducer;
@@ -30,8 +31,10 @@ public class ValidatorBean extends Build
 
     public ValidatorBean(WebBeansContext webBeansContext)
     {
-        super(webBeansContext, WebBeansType.VALIDATION, Validator.class);
-        setProducer(new ProviderBasedProxyProducer<Validator>(webBeansContext, Validator.class, new ValidatorProvider(webBeansContext)));
+        super(webBeansContext,
+              WebBeansType.VALIDATION,
+              Validator.class,
+              new SimpleProducerFactory<Validator>(new ProviderBasedProxyProducer<Validator>(webBeansContext, Validator.class, new ValidatorProvider(webBeansContext))));
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java (original)
+++ openwebbeans/trunk/webbeans-ee/src/main/java/org/apache/webbeans/ee/beans/ValidatorFactoryBean.java Sat Apr  6 19:04:24 2013
@@ -21,6 +21,7 @@ package org.apache.webbeans.ee.beans;
 import javax.validation.ValidatorFactory;
 
 import org.apache.webbeans.component.BuildInOwbBean;
+import org.apache.webbeans.component.SimpleProducerFactory;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.portable.ProviderBasedProxyProducer;
@@ -30,8 +31,11 @@ public class ValidatorFactoryBean extend
 
     public ValidatorFactoryBean(WebBeansContext webBeansContext)
     {
-        super(webBeansContext, WebBeansType.VALIDATIONFACT, ValidatorFactory.class);
-        setProducer(new ProviderBasedProxyProducer<ValidatorFactory>(webBeansContext, ValidatorFactory.class, new ValidatorFactoryProvider(webBeansContext)));
+        super(webBeansContext,
+              WebBeansType.VALIDATIONFACT,
+              ValidatorFactory.class,
+              new SimpleProducerFactory<ValidatorFactory>(
+                      new ProviderBasedProxyProducer<ValidatorFactory>(webBeansContext, ValidatorFactory.class, new ValidatorFactoryProvider(webBeansContext))));
     }
     
     @Override

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=1465291&r1=1465290&r2=1465291&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 Sat Apr  6 19:04:24 2013
@@ -18,8 +18,6 @@
  */
 package org.apache.webbeans.ejb.common.component;
 
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -76,22 +74,7 @@ public abstract class EjbBeanBuilder<T, 
     
     protected final E createBean(Class<T> beanClass)
     {
-        E bean =  createBean(beanClass, webBeansContext.getWebBeansUtil().isBeanEnabled(annotatedType, annotatedType.getJavaClass(), beanAttributes.getStereotypes()));
-
-        Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
-        for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean, annotatedType))
-        {
-            injectionPoints.add(injectionPoint);
-        }
-        InjectionTarget<T> injectionTarget = buildInjectionTarget(
-                bean.getAnnotatedType(),
-                injectionPoints,
-                webBeansContext,
-                Collections.<AnnotatedMethod<?>>emptyList(),
-                Collections.<AnnotatedMethod<?>>emptyList());
-        bean.setProducer(injectionTarget);
-
-        return bean;
+        return createBean(beanClass, webBeansContext.getWebBeansUtil().isBeanEnabled(annotatedType, annotatedType.getJavaClass(), beanAttributes.getStereotypes()));
     }
     
     protected abstract E createBean(Class<T> beanClass, boolean beanEnabled);

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=1465291&r1=1465290&r2=1465291&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 Sat Apr  6 19:04:24 2013
@@ -22,7 +22,6 @@ import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.util.Collections;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -64,9 +63,6 @@ public abstract class AbstractOwbBean<T>
     /**This bean is enabled or disabled*/
     protected boolean enabled = true;
 
-    /** The producer */
-    private Producer<T> producer;
-
     /**
      * This string will be used for passivating the Bean.
      * It will be created on the first use.
@@ -103,10 +99,7 @@ public abstract class AbstractOwbBean<T>
         return beanClass;
     }
     
-    public Producer<T> getProducer()
-    {
-        return producer;
-    }
+    public abstract Producer<T> getProducer();
     
     /**
      * {@inheritDoc}
@@ -120,6 +113,7 @@ public abstract class AbstractOwbBean<T>
                 creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, this);
             }
 
+            Producer<T> producer = getProducer();
             T instance = producer.produce(creationalContext);
             if (producer instanceof InjectionTarget)
             {
@@ -174,6 +168,7 @@ public abstract class AbstractOwbBean<T>
         }
         try
         {
+            Producer<T> producer = getProducer();
             if (producer instanceof InjectionTarget)
             {
                 InjectionTarget<T> injectionTarget = (InjectionTarget<T>)producer;
@@ -236,11 +231,6 @@ public abstract class AbstractOwbBean<T>
     /** cache previously calculated result */
     private Boolean isPassivationCapable = null;
 
-    public void setProducer(Producer<T> producer)
-    {
-        this.producer = producer;
-    }
-
     /**
      * Get web bean type of the bean.
      * 
@@ -268,11 +258,7 @@ public abstract class AbstractOwbBean<T>
      */    
     public Set<InjectionPoint> getInjectionPoints()
     {
-        if (producer == null)
-        {
-            return Collections.<InjectionPoint> emptySet();
-        }
-        return producer.getInjectionPoints();
+        return getProducer().getInjectionPoints();
     }
     
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java Sat Apr  6 19:04:24 2013
@@ -23,6 +23,9 @@ import java.lang.reflect.Modifier;
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.PassivationCapable;
+import javax.enterprise.inject.spi.Producer;
+
+import org.apache.webbeans.container.ProducerFactory;
 
 
 /**
@@ -36,6 +39,7 @@ public abstract class AbstractProducerBe
     /** Owner of the producer field component */
     protected InjectionTargetBean<?> ownerComponent;
     private Class<T> returnType;
+    private Producer<T> producer;
 
     /**
      * Create a new instance.
@@ -46,11 +50,19 @@ public abstract class AbstractProducerBe
     protected AbstractProducerBean(InjectionTargetBean<?> ownerComponent,
                                    WebBeansType webBeansType,
                                    BeanAttributesImpl<T> beanAttributes,
-                                   Class<T> returnType)
+                                   Class<T> returnType,
+                                   ProducerFactory<T> producerFactory)
     {
         super(ownerComponent.getWebBeansContext(), webBeansType, beanAttributes, ownerComponent.getBeanClass());
         this.ownerComponent = ownerComponent;
         this.returnType = returnType;
+        this.producer = producerFactory.createProducer(this);
+    }
+
+    @Override
+    public Producer<T> getProducer()
+    {
+        return producer;
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java Sat Apr  6 19:04:24 2013
@@ -27,15 +27,15 @@ import org.apache.webbeans.portable.Bean
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.CollectionUtil;
 
-public class BeanManagerBean extends AbstractOwbBean<BeanManager>
+public class BeanManagerBean extends BuildInOwbBean<BeanManager>
 {
     public BeanManagerBean(WebBeansContext webBeansContext)
     {
         super(webBeansContext,
               WebBeansType.MANAGER,
               new BeanAttributesImpl<BeanManager>(CollectionUtil.<Type>unmodifiableSet(BeanManager.class, Object.class), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION),
-              BeanManager.class);
-        setProducer(new BeanManagerProducer(webBeansContext));
+              BeanManager.class,
+              new SimpleProducerFactory<BeanManager>(new BeanManagerProducer(webBeansContext)));
     }
     
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java Sat Apr  6 19:04:24 2013
@@ -19,15 +19,39 @@
 package org.apache.webbeans.component;
 
 import java.lang.reflect.Type;
+
+import javax.enterprise.inject.spi.Producer;
+
+import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.CollectionUtil;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.ProducerFactory;
 
 public abstract class BuildInOwbBean<T> extends AbstractOwbBean<T>
 {
 
-    protected BuildInOwbBean(WebBeansContext webBeansContext, WebBeansType webBeansType, Class<T> returnType)
+    private Producer<T> producer;
+
+    protected BuildInOwbBean(WebBeansContext webBeansContext, WebBeansType webBeansType, Class<T> returnType, ProducerFactory<T> producerFactory)
+    {
+        this(webBeansContext, webBeansType, new BeanAttributesImpl<T>(CollectionUtil.<Type>unmodifiableSet(returnType, Object.class)), returnType, producerFactory);
+    }
+    
+    protected BuildInOwbBean(
+            WebBeansContext webBeansContext,
+            WebBeansType webBeansType,
+            BeanAttributesImpl<T> beanAttributes,
+            Class<T> returnType,
+            ProducerFactory<T> producerFactory)
+    {
+        super(webBeansContext, webBeansType, beanAttributes, returnType);
+        Asserts.assertNotNull(producerFactory, "ProducerFactory may not be null");
+        this.producer = producerFactory.createProducer(this);
+    }
+    
+    public Producer<T> getProducer()
     {
-        super(webBeansContext, webBeansType, new BeanAttributesImpl<T>(CollectionUtil.<Type>unmodifiableSet(returnType, Object.class)), returnType);
+        return producer;
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java Sat Apr  6 19:04:24 2013
@@ -36,7 +36,7 @@ import org.apache.webbeans.util.Collecti
  * @version $Rev$ $Date$
  *
  */
-public class ConversationBean extends InjectionTargetBean<ConversationImpl> implements InterceptedMarker
+public class ConversationBean extends BuildInOwbBean<ConversationImpl> implements InterceptedMarker
 {
     /**
      * Default constructor.
@@ -46,7 +46,6 @@ public class ConversationBean extends In
     {
         super(webBeansContext,
               WebBeansType.CONVERSATION,
-              webBeansContext.getAnnotatedElementFactory().newAnnotatedType(ConversationImpl.class),
               new BeanAttributesImpl<ConversationImpl>(
                       CollectionUtil.<Type>unmodifiableSet(Conversation.class, ConversationImpl.class, Object.class),
                       AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
@@ -55,8 +54,9 @@ public class ConversationBean extends In
                       false,
                       Collections.<Class<? extends Annotation>>emptySet(),
                       false),
-              ConversationImpl.class);
+              ConversationImpl.class,
+              new SimpleProducerFactory<ConversationImpl>(
+                      new ConversationProducer(webBeansContext.getAnnotatedElementFactory().newAnnotatedType(ConversationImpl.class), webBeansContext)));
         setEnabled(true);
-        setProducer(new ConversationProducer(getAnnotatedType(), webBeansContext));
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java Sat Apr  6 19:04:24 2013
@@ -25,6 +25,7 @@ import java.lang.reflect.Type;
 import java.util.Set;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.DecoratorInjectionTargetFactory;
 
 /**
  * Decorator Bean implementation.
@@ -53,7 +54,7 @@ public class DecoratorBean<T> extends In
                          BeanAttributesImpl<T> beanAttributes,
                          Class<T> beanClass)
     {
-        super(webBeansContext, webBeansType, annotatedType, beanAttributes, beanClass);
+        super(webBeansContext, webBeansType, annotatedType, beanAttributes, beanClass, new DecoratorInjectionTargetFactory<T>(annotatedType, webBeansContext));
     }
 
     public void setDecoratorInfo(Set<Type> decoratedTypes, Type delegateType, Set<Annotation> delegateQualifiers)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java Sat Apr  6 19:04:24 2013
@@ -32,7 +32,7 @@ import org.apache.webbeans.util.Collecti
  * 
  * @version $Rev$ $Date$
  */
-public class EventBean<T> extends AbstractOwbBean<Event<T>>
+public class EventBean<T> extends BuildInOwbBean<Event<T>>
 {
 
     /**
@@ -45,8 +45,8 @@ public class EventBean<T> extends Abstra
         super(webBeansContext,
               WebBeansType.OBSERVABLE,
               new BeanAttributesImpl<Event<T>>(CollectionUtil.<Type>unmodifiableSet(new TypeLiteral<Event<T>>() {}.getRawType(), Object.class)),
-              new TypeLiteral<Event<T>>(){}.getRawType());
-        setProducer(new EventProducer<T>(webBeansContext));
+              new TypeLiteral<Event<T>>(){}.getRawType(),
+              new SimpleProducerFactory<Event<T>>(new EventProducer<T>(webBeansContext)));
     }
     
     /* (non-Javadoc)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java Sat Apr  6 19:04:24 2013
@@ -21,7 +21,6 @@ package org.apache.webbeans.component;
 import javax.enterprise.context.ApplicationScoped;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.portable.ExtensionProducer;
 import org.apache.webbeans.util.AnnotationUtil;
 
 /**
@@ -31,8 +30,7 @@ import org.apache.webbeans.util.Annotati
  *
  * @param <T> type info
  */
-// TODO : Should not extend InjectionTargetBean, but AbstractOwbBean
-public class ExtensionBean<T> extends InjectionTargetBean<T>
+public class ExtensionBean<T> extends BuildInOwbBean<T>
 {
     /**
      * Creates a new extesion bean.
@@ -44,13 +42,11 @@ public class ExtensionBean<T> extends In
     {
         super(webBeansContext,
                 WebBeansType.EXTENSION,
-                webBeansContext.getAnnotatedElementFactory().newAnnotatedType(returnType),
                 new BeanAttributesImpl<T>(
                         webBeansContext.getAnnotatedElementFactory().getAnnotatedType(returnType).getTypeClosure(),
                         AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
                         ApplicationScoped.class),
-                returnType);
-        setEnabled(true);
-        setProducer(new ExtensionProducer<T>(getAnnotatedType(), getInjectionPoints(), webBeansContext));
+                returnType,
+                new ExtensionProducerFactory<T>(webBeansContext.getAnnotatedElementFactory().getAnnotatedType(returnType), webBeansContext));
     }
 }

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionProducerFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionProducerFactory.java?rev=1465291&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionProducerFactory.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionProducerFactory.java Sat Apr  6 19:04:24 2013
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Producer;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.ProducerFactory;
+import org.apache.webbeans.portable.ExtensionProducer;
+
+/**
+ * A factory for {@link javax.enterprise.inject.spi.Producer}s that produce CDI {@link javax.enterprise.inject.spi.Extension}s.
+ * 
+ * @version $Rev: 1440403 $ $Date: 2013-01-30 14:27:15 +0100 (Mi, 30 Jan 2013) $
+ */
+public class ExtensionProducerFactory<T> implements ProducerFactory<T>
+{
+
+    private AnnotatedType<T> annotatedType;
+    private WebBeansContext webBeansContext;
+
+    public ExtensionProducerFactory(AnnotatedType<T> annotatedType, WebBeansContext webBeansContext)
+    {
+        this.annotatedType = annotatedType;
+        this.webBeansContext = webBeansContext;
+    }
+
+    @Override
+    public Producer<T> createProducer(Bean<T> bean)
+    {
+        return new ExtensionProducer<T>(annotatedType, bean, webBeansContext);
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java Sat Apr  6 19:04:24 2013
@@ -26,15 +26,15 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.portable.InjectionPointProducer;
 import org.apache.webbeans.util.CollectionUtil;
 
-public class InjectionPointBean extends AbstractOwbBean<InjectionPoint>
+public class InjectionPointBean extends BuildInOwbBean<InjectionPoint>
 {
     public InjectionPointBean(WebBeansContext webBeansContext)
     {
         super(webBeansContext,
               WebBeansType.INJECTIONPOINT,
               new BeanAttributesImpl<InjectionPoint>(CollectionUtil.<Type>unmodifiableSet(InjectionPoint.class, Object.class)),
-              InjectionPoint.class);
-        setProducer(new InjectionPointProducer());
+              InjectionPoint.class,
+              new SimpleProducerFactory<InjectionPoint>(new InjectionPointProducer()));
     }
 
     /* (non-Javadoc)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java Sat Apr  6 19:04:24 2013
@@ -29,6 +29,7 @@ import java.util.Map;
 import javax.enterprise.inject.spi.AnnotatedType;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.InjectionTargetFactoryImpl;
 
 import javax.enterprise.inject.spi.InjectionTarget;
 import javax.enterprise.inject.spi.InterceptionType;
@@ -51,6 +52,16 @@ public abstract class InjectionTargetBea
 {    
     /**Annotated type for bean*/
     private AnnotatedType<T> annotatedType;
+    private InjectionTarget<T> injectionTarget;
+
+    protected InjectionTargetBean(WebBeansContext webBeansContext,
+            WebBeansType webBeansType,
+            AnnotatedType<T> annotatedType,
+            BeanAttributesImpl<T> beanAttributes,
+            Class<T> beanClass)
+    {
+        this(webBeansContext, webBeansType, annotatedType, beanAttributes, beanClass, new InjectionTargetFactoryImpl<T>(annotatedType, webBeansContext));
+    }
 
     /**
      * Initializes the InjectionTarget Bean part.
@@ -59,17 +70,24 @@ public abstract class InjectionTargetBea
                                   WebBeansType webBeansType,
                                   AnnotatedType<T> annotatedType,
                                   BeanAttributesImpl<T> beanAttributes,
-                                  Class<T> beanClass)
+                                  Class<T> beanClass,
+                                  InjectionTargetFactoryImpl<T> factory)
     {
         super(webBeansContext, webBeansType, beanAttributes, beanClass);
         Asserts.assertNotNull(annotatedType, "AnnotatedType may not be null");
         this.annotatedType = annotatedType;
+        this.injectionTarget = factory.createInjectionTarget(this);
         setEnabled(true);
     }
 
+    public InjectionTarget<T> getProducer()
+    {
+        return injectionTarget;
+    }
+
     public InjectionTarget<T> getInjectionTarget()
     {
-        return (InjectionTarget<T>) getProducer();
+        return injectionTarget;
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java Sat Apr  6 19:04:24 2013
@@ -29,7 +29,7 @@ import org.apache.webbeans.portable.Inst
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.CollectionUtil;
 
-public class InstanceBean<T> extends AbstractOwbBean<Instance<T>>
+public class InstanceBean<T> extends BuildInOwbBean<Instance<T>>
 {
     
     @SuppressWarnings("serial")
@@ -41,8 +41,9 @@ public class InstanceBean<T> extends Abs
                       new TypeLiteral<Instance<T>>(){}.getRawType(), 
                       new TypeLiteral<Provider<T>>() {}.getRawType(), 
                       Object.class)),
-              new TypeLiteral<Instance<T>>(){}.getRawType());
-        setProducer(new InstanceProducer<T>(getReturnType(), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION, webBeansContext));
+              new TypeLiteral<Instance<T>>(){}.getRawType(),
+              new SimpleProducerFactory<Instance<T>>(
+                      new InstanceProducer<T>(new TypeLiteral<Instance<T>>(){}.getRawType(), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION, webBeansContext)));
     }
 
     /* (non-Javadoc)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java Sat Apr  6 19:04:24 2013
@@ -30,6 +30,7 @@ import java.util.Collections;
 import java.util.Map;
 
 import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.InterceptorInjectionTargetFactory;
 import org.apache.webbeans.util.ExceptionUtil;
 
 /**
@@ -63,7 +64,8 @@ public abstract class InterceptorBean<T>
               WebBeansType.INTERCEPTOR,
               annotatedType,
               beanAttributes,
-              beanClass);
+              beanClass,
+              new InterceptorInjectionTargetFactory<T>(annotatedType, webBeansContext));
         this.interceptionMethods = Collections.unmodifiableMap(interceptionMethods);
 
         for (Method[] methods: interceptionMethods.values())

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.java Sat Apr  6 19:04:24 2013
@@ -18,15 +18,12 @@
  */
 package org.apache.webbeans.component;
 
-import java.util.Collections;
 import java.util.Set;
 
-import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.InjectionPoint;
 
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.portable.InjectionTargetImpl;
 
 /**
  * Component definition with {@link javax.enterprise.inject.New} binding annotation.
@@ -47,8 +44,6 @@ public class NewManagedBean<T> extends M
                           Set<InjectionPoint> injectionPoints)
     {
         super(webBeansContext, webBeansType, annotatedType, beanAttributes, beanClass);
-        setProducer(new InjectionTargetImpl<T>(
-                annotatedType, injectionPoints, webBeansContext, Collections.<AnnotatedMethod<?>>emptyList(), Collections.<AnnotatedMethod<?>>emptyList()));
     }
 
     /**

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=1465291&r1=1465290&r2=1465291&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 Sat Apr  6 19:04:24 2013
@@ -39,13 +39,6 @@ public interface OwbBean<T> extends Bean
     public Producer<T> getProducer();
 
     /**
-     * Sets the producer for this bean
-     *
-     * @param producer
-     */
-    public void setProducer(Producer<T> producer);
-
-    /**
      * Returns bean type.
      * 
      * @return webbeans type

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java Sat Apr  6 19:04:24 2013
@@ -23,6 +23,7 @@ import java.lang.reflect.Field;
 
 import javax.enterprise.context.spi.CreationalContext;
 
+import org.apache.webbeans.container.ProducerFactory;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
@@ -42,9 +43,9 @@ public class ProducerFieldBean<T> extend
      * 
      * @param returnType type of the field decleration
      */
-    public ProducerFieldBean(InjectionTargetBean<?> ownerComponent, BeanAttributesImpl<T> beanAttributes, Class<T> returnType)
+    public ProducerFieldBean(InjectionTargetBean<?> ownerComponent, BeanAttributesImpl<T> beanAttributes, Class<T> returnType, ProducerFactory<T> producerFactory)
     {
-        super(ownerComponent, WebBeansType.PRODUCERFIELD, beanAttributes, returnType);
+        super(ownerComponent, WebBeansType.PRODUCERFIELD, beanAttributes, returnType, producerFactory);
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java Sat Apr  6 19:04:24 2013
@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
 
 import javax.enterprise.context.spi.CreationalContext;
 
+import org.apache.webbeans.component.creation.MethodProducerFactory;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -52,9 +53,10 @@ public class ProducerMethodBean<T> exten
      */
     public <P> ProducerMethodBean(InjectionTargetBean<P> ownerComponent,
                                   BeanAttributesImpl<T> beanAttributes,
-                                  Class<T> returnType)
+                                  Class<T> returnType,
+                                  MethodProducerFactory<T, P> producerFactory)
     {
-        super(ownerComponent, WebBeansType.PRODUCERMETHOD, beanAttributes, returnType);
+        super(ownerComponent, WebBeansType.PRODUCERMETHOD, beanAttributes, returnType, producerFactory);
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java Sat Apr  6 19:04:24 2013
@@ -20,6 +20,7 @@ package org.apache.webbeans.component;
 
 import java.lang.annotation.Annotation;
 
+import org.apache.webbeans.portable.ProviderBasedProxyProducerFactory;
 import org.apache.webbeans.spi.ResourceInjectionService;
 import org.apache.webbeans.spi.api.ResourceReference;
 
@@ -33,7 +34,12 @@ public class ResourceBean<X, T extends A
                         BeanAttributesImpl<X> beanAttributes,
                         Class<X> beanClass)
     {
-        super(ownerComponent, beanAttributes, beanClass);
+        super(ownerComponent,
+              beanAttributes,
+              beanClass,
+              new ProviderBasedProxyProducerFactory<X>(new ResourceProvider<X>(resourceReference, ownerComponent.getWebBeansContext()),
+                                                       beanClass,
+                                                       ownerComponent.getWebBeansContext()));
         this.resourceReference = resourceReference;
     }
     

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SimpleProducerFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SimpleProducerFactory.java?rev=1465291&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SimpleProducerFactory.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SimpleProducerFactory.java Sat Apr  6 19:04:24 2013
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Producer;
+
+import org.apache.webbeans.container.ProducerFactory;
+
+/**
+ * @version $Rev: 1440403 $ $Date: 2013-01-30 14:27:15 +0100 (Mi, 30 Jan 2013) $
+ */
+public class SimpleProducerFactory<T> implements ProducerFactory<T>
+{
+
+    private Producer<T> producer;
+
+    public SimpleProducerFactory(Producer<T> producer)
+    {
+        this.producer = producer;
+    }
+
+    @Override
+    public Producer<T> createProducer(Bean<T> bean)
+    {
+        return producer;
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java Sat Apr  6 19:04:24 2013
@@ -53,7 +53,7 @@ public abstract class AbstractProducerBe
         return parent.getWebBeansContext().getAnnotatedElementFactory().getAnnotatedType(superclass);
     }
 
-    protected abstract P createBean(InjectionTargetBean<?> parent, Class<T> beanClass);
+    protected abstract <X> P createBean(InjectionTargetBean<X> parent, Class<T> beanClass);
 
     protected P createBean(Class<T> beanClass)
     {

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=1465291&r1=1465290&r2=1465291&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 Sat Apr  6 19:04:24 2013
@@ -24,17 +24,14 @@ import javax.decorator.Delegate;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Alternative;
 import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.AnnotatedConstructor;
 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.InjectionTarget;
 import javax.inject.Inject;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Constructor;
-import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.lang.reflect.TypeVariable;
 import java.util.ArrayList;
@@ -53,8 +50,6 @@ import org.apache.webbeans.config.OwbPar
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
-import org.apache.webbeans.portable.AnnotatedConstructorImpl;
-import org.apache.webbeans.portable.InjectionTargetImpl;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 
@@ -275,33 +270,10 @@ public class DecoratorBeanBuilder<T>
         }
     }
 
-    protected InjectionTarget<T> buildInjectionTarget(AnnotatedType<T> annotatedType, Set<InjectionPoint> points,
-                                                      WebBeansContext webBeansContext, List<AnnotatedMethod<?>> postConstructMethods, List<AnnotatedMethod<?>> preDestroyMethods)
-    {
-        InjectionTarget<T> injectionTarget;
-
-        if (Modifier.isAbstract(annotatedType.getJavaClass().getModifiers()))
-        {
-            injectionTarget = new AbstractDecoratorInjectionTarget<T>(annotatedType, points, webBeansContext, postConstructMethods, preDestroyMethods);
-        }
-        else
-        {
-            injectionTarget = new InjectionTargetImpl<T>(annotatedType, points, webBeansContext, postConstructMethods, preDestroyMethods);
-        }
-        return injectionTarget;
-    }
-
     public DecoratorBean<T> getBean()
     {
         DecoratorBean<T> decorator = new DecoratorBean<T>(webBeansContext, WebBeansType.MANAGED, annotatedType, beanAttributes, annotatedType.getJavaClass());
         decorator.setEnabled(webBeansContext.getDecoratorsManager().isDecoratorEnabled(annotatedType.getJavaClass()));
-        Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
-        for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(decorator, annotatedType))
-        {
-            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());
@@ -359,33 +331,4 @@ public class DecoratorBeanBuilder<T>
             }
         }
     }
-
-    /**
-     * Helper class to swap out the constructor for the proxied subclass.
-     */
-    private static class AbstractDecoratorInjectionTarget<T> extends InjectionTargetImpl<T>
-    {
-        private Class<T> proxySubClass = null;
-
-        private AbstractDecoratorInjectionTarget(AnnotatedType<T> annotatedType, Set<InjectionPoint> points, WebBeansContext webBeansContext,
-                                                 List<AnnotatedMethod<?>> postConstructMethods, List<AnnotatedMethod<?>> preDestroyMethods)
-        {
-            super(annotatedType, points, webBeansContext, postConstructMethods, preDestroyMethods);
-        }
-
-        @Override
-        protected AnnotatedConstructor<T> createConstructor()
-        {
-            // create proxy subclass
-            ClassLoader classLoader = this.getClass().getClassLoader();
-            Class<T> classToProxy = annotatedType.getJavaClass();
-
-            proxySubClass = webBeansContext.getSubclassProxyFactory().createImplementedSubclass(classLoader, classToProxy);
-
-            //X TODO what about @Inject constructors?
-            Constructor<T> ct = webBeansContext.getWebBeansUtil().getNoArgConstructor(proxySubClass);
-            return new AnnotatedConstructorImpl<T>(webBeansContext, ct, annotatedType);
-        }
-
-    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java Sat Apr  6 19:04:24 2013
@@ -37,6 +37,11 @@ public class ExtensionBeanBuilder<T>
         this.annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(type);
     }
 
+    public AnnotatedType<T> getAnnotatedType()
+    {
+        return annotatedType;
+    }
+
     public ExtensionBean<T> getBean()
     {
         return new ExtensionBean<T>(webBeansContext, annotatedType.getJavaClass());

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.java?rev=1465291&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/FieldProducerFactory.java Sat Apr  6 19:04:24 2013
@@ -0,0 +1,52 @@
+/*
+ * 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.AnnotatedField;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Producer;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.ProducerFactory;
+import org.apache.webbeans.portable.ProducerFieldProducer;
+import org.apache.webbeans.util.Asserts;
+
+public class FieldProducerFactory<T, P> implements ProducerFactory<T>
+{
+
+    private AnnotatedField<? super P> producerField;
+    private Bean<P> parent;
+    private WebBeansContext webBeansContext;
+
+    public FieldProducerFactory(AnnotatedField<? super P> producerField, Bean<P> parent, WebBeansContext webBeansContext)
+    {
+        Asserts.assertNotNull(producerField, "producer method may not be null");
+        Asserts.assertNotNull(webBeansContext, "WebBeansContext may not be null");
+        this.producerField = producerField;
+        this.parent = parent;
+        this.webBeansContext = webBeansContext;
+    }
+
+    @Override
+    public Producer<T> createProducer(Bean<T> bean)
+    {
+        Producer<T> producer = new ProducerFieldProducer<T, P>(parent, producerField, webBeansContext);
+        return webBeansContext.getWebBeansUtil().fireProcessProducerEvent(producer, producerField);
+    }
+}

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=1465291&r1=1465290&r2=1465291&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 Sat Apr  6 19:04:24 2013
@@ -24,8 +24,6 @@ import javax.enterprise.inject.Produces;
 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.InjectionTarget;
 import javax.enterprise.inject.spi.InterceptionType;
 import javax.interceptor.AroundInvoke;
 import javax.interceptor.AroundTimeout;
@@ -35,9 +33,7 @@ import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 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;
@@ -47,7 +43,6 @@ import org.apache.webbeans.component.Int
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
-import org.apache.webbeans.portable.InjectionTargetImpl;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 
@@ -331,19 +326,6 @@ public abstract class InterceptorBeanBui
 
     public B getBean()
     {
-        B bean = createBean(annotatedType.getJavaClass(), isInterceptorEnabled(), interceptionMethods);
-        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(),
-                injectionPoints,
-                webBeansContext,
-                Collections.<AnnotatedMethod<?>>emptyList(),
-                Collections.<AnnotatedMethod<?>>emptyList());
-        bean.setProducer(injectionTarget);
-        return bean;
+        return createBean(annotatedType.getJavaClass(), isInterceptorEnabled(), interceptionMethods);
     }
 }

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=1465291&r1=1465290&r2=1465291&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 Sat Apr  6 19:04:24 2013
@@ -18,22 +18,12 @@
  */
 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;
-import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.InjectionTarget;
 
 import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.portable.InjectionTargetImpl;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.WebBeansUtil;
 
@@ -71,27 +61,9 @@ 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))
-        {
-            injectionPoints.add(injectionPoint);
-        }
-        InjectionTarget<T> injectionTarget
-            = new InjectionTargetImpl<T>(bean.getAnnotatedType(), injectionPoints, webBeansContext, getPostConstructMethods(), getPreDestroyMethods());
-        bean.setProducer(injectionTarget);
         webBeansContext.getWebBeansUtil().checkManagedBeanCondition(annotatedType);
         WebBeansUtil.checkGenericType(annotatedType.getJavaClass(), beanAttributes.getScope());
         webBeansContext.getDeploymentValidationService().validateProxyable(bean);
         return bean;
     }
-
-    protected List<AnnotatedMethod<?>> getPostConstructMethods()
-    {
-        return webBeansContext.getInterceptorUtil().getLifecycleMethods(annotatedType, PostConstruct.class, true);
-    }
-
-    protected List<AnnotatedMethod<?>> getPreDestroyMethods()
-    {
-        return webBeansContext.getInterceptorUtil().getLifecycleMethods(annotatedType, PreDestroy.class, false);
-    }
 }

Copied: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java (from r1451507, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodProducerBuilder.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java?p2=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java&p1=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodProducerBuilder.java&r1=1451507&r2=1465291&rev=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodProducerBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/MethodProducerFactory.java Sat Apr  6 19:04:24 2013
@@ -29,42 +29,47 @@ import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.Producer;
 import javax.inject.Inject;
 import javax.inject.Named;
 
-import org.apache.webbeans.component.OwbBean;
-import org.apache.webbeans.component.ProducerMethodBean;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.container.ProducerFactory;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.portable.ProducerMethodProducer;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
 
-public class ProducerMethodProducerBuilder<T, P>
+public class MethodProducerFactory<T, P> implements ProducerFactory<T>
 {
 
-    private ProducerMethodBean<T> bean;
-    private AnnotatedMethod<P> producerMethod;
-    private AnnotatedMethod<P> disposalMethod;
-    private Set<InjectionPoint> injectionPoints;
+    private AnnotatedMethod<? super P> producerMethod;
+    private AnnotatedMethod<? super P> disposalMethod;
+    private Bean<P> parent;
+    private WebBeansContext webBeansContext;
 
-    public ProducerMethodProducerBuilder(ProducerMethodBean<T> producerMethodBean)
+    public MethodProducerFactory(AnnotatedMethod<? super P> producerMethod, Bean<P> parent, WebBeansContext webBeansContext)
     {
-        Asserts.assertNotNull(producerMethodBean);
-        this.bean = producerMethodBean;
+        Asserts.assertNotNull(producerMethod, "producer method may not be null");
+        Asserts.assertNotNull(webBeansContext, "WebBeansContext may not be null");
+        this.producerMethod = producerMethod;
+        this.parent = parent;
+        this.webBeansContext = webBeansContext;
+        defineDisposalMethod();
     }
 
-    public ProducerMethodProducer<T, P> build(AnnotatedMethod<P> method)
+    @Override
+    public Producer<T> createProducer(Bean<T> bean)
     {
-        producerMethod = method;
-        defineDisposalMethod();
-        defineInjectionPoints();
-        return new ProducerMethodProducer<T, P>((OwbBean<P>) bean.getParent(), producerMethod, disposalMethod, injectionPoints);
+        Producer<T> producer = new ProducerMethodProducer<T, P>(parent, producerMethod, disposalMethod, createInjectionPoints(bean), webBeansContext);
+        return webBeansContext.getWebBeansUtil().fireProcessProducerEvent(producer, producerMethod);
     }
 
     private void defineDisposalMethod()
     {
-        Set<Annotation> producerQualifiers = bean.getWebBeansContext().getAnnotationManager().getQualifierAnnotations(producerMethod.getAnnotations());
+        Set<Annotation> producerQualifiers = webBeansContext.getAnnotationManager().getQualifierAnnotations(producerMethod.getAnnotations());
         if (producerQualifiers.size() == 1 && producerQualifiers.iterator().next().annotationType().equals(Default.class))
         {
             producerQualifiers = Collections.emptySet();
@@ -77,7 +82,7 @@ public class ProducerMethodProducerBuild
                 producerQualifiersWithoutNamed.add(qualifier);
             }
         }
-        Set<AnnotatedMethod<? super P>> annotatedMethods = producerMethod.getDeclaringType().getMethods();        
+        Set<AnnotatedMethod<? super P>> annotatedMethods = (Set<AnnotatedMethod<? super P>>)(Set<?>)producerMethod.getDeclaringType().getMethods();        
         for (AnnotatedMethod<? super P> annotatedMethod : annotatedMethods)
         {            
             if (annotatedMethod.getDeclaringType().equals(producerMethod.getDeclaringType()))
@@ -87,7 +92,7 @@ public class ProducerMethodProducerBuild
                     if (annotatedParameter.isAnnotationPresent(Disposes.class))
                     {
                         Set<Annotation> producerQualifiersToCompare = producerQualifiers;
-                        Set<Annotation> disposalQualifiers = bean.getWebBeansContext().getAnnotationManager().getQualifierAnnotations(annotatedParameter.getAnnotations());
+                        Set<Annotation> disposalQualifiers = webBeansContext.getAnnotationManager().getQualifierAnnotations(annotatedParameter.getAnnotations());
                         if (disposalQualifiers.size() == 1 && disposalQualifiers.iterator().next().annotationType().equals(Default.class))
                         {
                             disposalQualifiers = Collections.emptySet();
@@ -168,12 +173,13 @@ public class ProducerMethodProducerBuild
         }        
     }
 
-    private void defineInjectionPoints()
+    protected Set<InjectionPoint> createInjectionPoints(Bean<T> bean)
     {
-        injectionPoints = new HashSet<InjectionPoint>(bean.getWebBeansContext().getInjectionPointFactory().buildInjectionPoints(bean, producerMethod));
+        Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>(webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean, producerMethod));
         if (disposalMethod != null)
         {
-            injectionPoints.addAll(bean.getWebBeansContext().getInjectionPointFactory().buildInjectionPoints(bean, disposalMethod));
+            injectionPoints.addAll(webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean, disposalMethod));
         }
+        return injectionPoints;
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ObserverMethodsBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ObserverMethodsBuilder.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ObserverMethodsBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ObserverMethodsBuilder.java Sat Apr  6 19:04:24 2013
@@ -34,6 +34,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.inject.Inject;
 
+import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -68,7 +69,7 @@ public class ObserverMethodsBuilder<T, I
     /**
      * {@inheritDoc}
      */
-    public Set<ObserverMethod<?>> defineObserverMethods(InjectionTargetBean<T> bean)
+    public Set<ObserverMethod<?>> defineObserverMethods(AbstractOwbBean<T> bean)
     {   
         Set<ObserverMethod<?>> definedObservers = new HashSet<ObserverMethod<?>>();
         Set<AnnotatedMethod<? super T>> annotatedMethods = annotatedType.getMethods();    

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java Sat Apr  6 19:04:24 2013
@@ -47,9 +47,9 @@ public class ProducerFieldBeanBuilder<T,
     }
 
     @Override
-    protected P createBean(InjectionTargetBean<?> owner, Class<T> beanClass)
+    protected <X> P createBean(InjectionTargetBean<X> owner, Class<T> beanClass)
     {
-        return (P) new ProducerFieldBean<T>(owner, beanAttributes, beanClass);
+        return (P) new ProducerFieldBean<T>(owner, beanAttributes, beanClass, new FieldProducerFactory(annotatedMember, owner, owner.getWebBeansContext()));
     }
     
     public P getBean()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeansBuilder.java Sat Apr  6 19:04:24 2013
@@ -35,11 +35,8 @@ import org.apache.webbeans.component.Bea
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.ResourceBean;
-import org.apache.webbeans.component.ResourceProvider;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.portable.ProducerFieldProducer;
-import org.apache.webbeans.portable.ProviderBasedProxyProducer;
 import org.apache.webbeans.spi.api.ResourceReference;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
@@ -121,12 +118,7 @@ public class ProducerFieldBeansBuilder<T
                         ResourceBeanBuilder<T, Annotation> resourceBeanCreator
                             = new ResourceBeanBuilder<T, Annotation>(bean, resourceRef, annotatedField, beanAttributes);
                         ResourceBean<T, Annotation> resourceBean = resourceBeanCreator.getBean();
-                        ResourceProvider<T> resourceProvider = new ResourceProvider<T>(resourceBean.getReference(), webBeansContext);
-                        resourceBean.setProducer(new ProviderBasedProxyProducer<T>(webBeansContext, resourceBean.getReturnType(), resourceProvider));
-
-
                         resourceBean.setProducerField(field);
-                        
                         producerBeans.add(resourceBean);                                            
                     }
                 }
@@ -137,7 +129,6 @@ public class ProducerFieldBeansBuilder<T
                         = new ProducerFieldBeanBuilder<T, ProducerFieldBean<T>>(bean, annotatedField, beanAttributes);
                     ProducerFieldBean<T> producerFieldBean = producerFieldBeanCreator.getBean();
                     webBeansContext.getDeploymentValidationService().validateProxyable(producerFieldBean);
-                    producerFieldBean.setProducer(new ProducerFieldProducer(bean, annotatedField, producerFieldBean.getInjectionPoints()));
                     producerFieldBean.setProducerField(field);
 
                     webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(bean, producerFieldBean, anns);

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=1465291&r1=1465290&r2=1465291&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 Sat Apr  6 19:04:24 2013
@@ -104,9 +104,11 @@ public class ProducerMethodBeanBuilder<T
     }
 
     @Override
-    protected ProducerMethodBean<T> createBean(InjectionTargetBean<?> parent, Class<T> beanClass)
+    protected <P> ProducerMethodBean<T> createBean(InjectionTargetBean<P> parent, Class<T> beanClass)
     {
-        ProducerMethodBean<T> producerMethodBean = new ProducerMethodBean<T>(parent, beanAttributes, beanClass);
+        AnnotatedMethod<P> annotatedMethod = (AnnotatedMethod<P>) annotatedMember;
+        ProducerMethodBean<T> producerMethodBean
+            = new ProducerMethodBean<T>(parent, beanAttributes, beanClass, new MethodProducerFactory<T, P>(annotatedMethod, parent, parent.getWebBeansContext()));
         producerMethodBean.setSpecializedBean(specialized);
         return producerMethodBean;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeansBuilder.java Sat Apr  6 19:04:24 2013
@@ -98,8 +98,7 @@ public class ProducerMethodBeansBuilder<
                 {
                     producerMethodBeanCreator.configureProducerSpecialization(producerMethodBean, (AnnotatedMethod<T>) annotatedMethod);
                 }
-                ProducerMethodProducerBuilder producerBuilder = new ProducerMethodProducerBuilder(producerMethodBean);
-                producerMethodBean.setProducer(producerBuilder.build(annotatedMethod));
+                MethodProducerFactory<T, ?> producerFactory = new MethodProducerFactory(annotatedMethod, bean, webBeansContext);
                 producerMethodBean.setCreatorMethod(annotatedMethod.getJavaMember());
                 
                 webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(bean,

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java Sat Apr  6 19:04:24 2013
@@ -39,7 +39,7 @@ public class ResourceBeanBuilder<T, R ex
     }
 
     @Override
-    protected ResourceBean<T, R> createBean(InjectionTargetBean<?> owner, Class<T> beanClass)
+    protected <X> ResourceBean<T, R> createBean(InjectionTargetBean<X> owner, Class<T> beanClass)
     {
         return new ResourceBean<T, R>(owner, resourceRef, beanAttributes, beanClass);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java?rev=1465291&r1=1465290&r2=1465291&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java Sat Apr  6 19:04:24 2013
@@ -25,6 +25,7 @@ import javax.enterprise.context.spi.Crea
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.PassivationCapable;
+import javax.enterprise.inject.spi.Producer;
 
 import org.apache.webbeans.component.AbstractOwbBean;
 import org.apache.webbeans.component.BeanAttributesImpl;
@@ -48,6 +49,31 @@ public class ThirdpartyBeanImpl<T> exten
     }
 
     @Override
+    public Producer<T> getProducer()
+    {
+        return new Producer<T>()
+        {
+            @Override
+            public T produce(CreationalContext<T> creationalContext)
+            {
+                return bean.create(creationalContext);
+            }
+
+            @Override
+            public void dispose(T instance)
+            {
+                bean.destroy(instance, null);
+            }
+
+            @Override
+            public Set<InjectionPoint> getInjectionPoints()
+            {
+                return bean.getInjectionPoints();
+            }
+        };
+    }
+
+    @Override
     public Set<InjectionPoint> getInjectionPoints()
     {
         return bean.getInjectionPoints();

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=1465291&r1=1465290&r2=1465291&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 Sat Apr  6 19:04:24 2013
@@ -43,10 +43,8 @@ import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Decorator;
 import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.InjectionTarget;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import javax.enterprise.inject.spi.Producer;
 
 import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.component.BeanAttributesImpl;
@@ -82,7 +80,6 @@ import org.apache.webbeans.portable.Anno
 import org.apache.webbeans.portable.events.ProcessAnnotatedTypeImpl;
 import org.apache.webbeans.portable.events.ProcessBeanImpl;
 import org.apache.webbeans.portable.events.ProcessInjectionTargetImpl;
-import org.apache.webbeans.portable.events.ProcessProducerImpl;
 import org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl;
 import org.apache.webbeans.portable.events.discovery.AfterDeploymentValidationImpl;
 import org.apache.webbeans.portable.events.discovery.BeforeBeanDiscoveryImpl;
@@ -878,12 +875,6 @@ public class BeansDeployer
             
                 bean = managedBeanCreator.getBean();
 
-                if(processInjectionTargetEvent == null)
-                {
-                    processInjectionTarget = webBeansContext.getWebBeansUtil().createProcessInjectionTargetEvent(bean);
-                    processInjectionTargetEvent = processInjectionTarget;
-                }
-
                 if (webBeansContext.getDecoratorsManager().containsCustomDecoratorClass(annotatedType.getJavaClass()) ||
                     webBeansContext.getInterceptorsManager().containsCustomInterceptorClass(annotatedType.getJavaClass()))
                 {
@@ -903,9 +894,6 @@ public class BeansDeployer
                 Set<ProducerMethodBean<?>> producerMethods = new ProducerMethodBeansBuilder(bean.getWebBeansContext(), bean.getAnnotatedType()).defineProducerMethods(bean);
                 Set<ProducerFieldBean<?>> producerFields = new ProducerFieldBeansBuilder(bean.getWebBeansContext(), bean.getAnnotatedType()).defineProducerFields(bean);
 
-                //Put final InjectionTarget instance
-                bean.setProducer(processInjectionTargetEvent.getInjectionTarget());
-
                 ManagedBean<T> managedBean = (ManagedBean<T>)bean;
                 Map<ProducerMethodBean<?>,AnnotatedMethod<?>> annotatedMethods =
                         new HashMap<ProducerMethodBean<?>, AnnotatedMethod<?>>();
@@ -913,13 +901,10 @@ public class BeansDeployer
                 for(ProducerMethodBean<?> producerMethod : producerMethods)
                 {
                     AnnotatedMethod<?> method = webBeansContext.getAnnotatedElementFactory().newAnnotatedMethod(producerMethod.getCreatorMethod(), annotatedType);
-                    ProcessProducerImpl<?, ?> producerEvent = webBeansContext.getWebBeansUtil().fireProcessProducerEventForMethod(producerMethod,
-                            method);
                     webBeansContext.getWebBeansUtil().inspectErrorStack("There are errors that are added by ProcessProducer event observers for "
                             + "ProducerMethods. Look at logs for further details");
 
                     annotatedMethods.put(producerMethod, method);
-                    producerMethod.setProducer((Producer) producerEvent.getProducer());
                 }
 
                 Map<ProducerFieldBean<?>,AnnotatedField<?>> annotatedFields =
@@ -927,13 +912,10 @@ public class BeansDeployer
 
                 for(ProducerFieldBean<?> producerField : producerFields)
                 {
-                    AnnotatedField<?> field = webBeansContext.getAnnotatedElementFactory().newAnnotatedField(producerField.getCreatorField(), annotatedType);
-                    ProcessProducerImpl<?, ?> producerEvent = webBeansContext.getWebBeansUtil().fireProcessProducerEventForField(producerField, field);
                     webBeansContext.getWebBeansUtil().inspectErrorStack("There are errors that are added by ProcessProducer event observers for"
                             + " ProducerFields. Look at logs for further details");
 
-                    annotatedFields.put(producerField, field);
-                    producerField.setProducer((Producer) producerEvent.getProducer());
+                    annotatedFields.put(producerField, null);
                 }
 
                 Map<ObserverMethod<?>,AnnotatedMethod<?>> observerMethodsMap =
@@ -985,21 +967,6 @@ public class BeansDeployer
                     }
                 }
             }
-
-            if(processInjectionTarget != null)
-            {
-                if(processInjectionTargetEvent != null)
-                {
-                    final InjectionTarget originalInjectionTarget = bean.getInjectionTarget();
-                    final InjectionTarget updatedInjectionTarget = webBeansContext.getWebBeansUtil()
-                            .fireProcessInjectionTargetEvent(bean).getInjectionTarget();
-                    if (updatedInjectionTarget != originalInjectionTarget && bean != null)
-                    {
-                        bean.setProducer(updatedInjectionTarget);
-                    }
-                }
-            }
-
             return true;
         }
         else



Mime
View raw message