[webbeans-commits] Webbeans SVN: r894 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: injection and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon Jan 12 11:34:17 EST 2009


Author: gavin.king at jboss.com
Date: 2009-01-12 11:34:17 -0500 (Mon, 12 Jan 2009)
New Revision: 894

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java
Log:
ditch getInstance()

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-01-12 16:32:43 UTC (rev 893)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-01-12 16:34:17 UTC (rev 894)
@@ -422,7 +422,6 @@
       try
       {
          manager.getInjectionPointFactory().pushBean(this);
-         manager.getInjectionPointFactory().pushInstance(this);
          DependentContext.INSTANCE.setActive(true);
          bindDecorators();
          bindInterceptors();
@@ -432,7 +431,6 @@
       }
       finally
       {
-         manager.getInjectionPointFactory().popInstance();
          manager.getInjectionPointFactory().popBean();
          DependentContext.INSTANCE.setActive(false);
       }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2009-01-12 16:32:43 UTC (rev 893)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2009-01-12 16:34:17 UTC (rev 894)
@@ -122,20 +122,12 @@
          try
          {
             instance = constructor.newInstance(manager);
-            try
-            {
-               injectionPointProvider.pushInstance(instance);
-               bindDecorators();
-               bindInterceptors();
-               injectEjbAndCommonFields(instance);
-               injectBoundFields(instance);
-               callInitializers(instance);
-               callPostConstruct(instance);
-            }
-            finally
-            {
-               injectionPointProvider.popInstance();
-            }
+            bindDecorators();
+            bindInterceptors();
+            injectEjbAndCommonFields(instance);
+            injectBoundFields(instance);
+            callInitializers(instance);
+            callPostConstruct(instance);
          }
          finally
          {
@@ -236,14 +228,14 @@
    {
       for (AnnotatedField<?> field : annotatedItem.getAnnotatedFields(manager.getEjbResolver().getEJBAnnotation()))
       {
-         InjectionPoint injectionPoint = new InjectionPointImpl(field, this, beanInstance);
+         InjectionPoint injectionPoint = new InjectionPointImpl(field, this);
          Object ejbInstance = manager.getEjbResolver().resolveEjb(injectionPoint, manager.getNaming());
          field.inject(beanInstance, ejbInstance);
       }
 
       for (AnnotatedMethod<?> method : annotatedItem.getAnnotatedMethods(manager.getEjbResolver().getEJBAnnotation()))
       {
-         InjectionPoint injectionPoint = new InjectionPointImpl(method, this, beanInstance);
+         InjectionPoint injectionPoint = new InjectionPointImpl(method, this);
          Object ejbInstance = manager.getEjbResolver().resolveEjb(injectionPoint, manager.getNaming());
          method.invoke(beanInstance, ejbInstance);
       }
@@ -254,21 +246,21 @@
          {
             throw new ExecutionException("Cannot inject an extended persistence context into " + field);
          }
-         InjectionPoint injectionPoint = new InjectionPointImpl(field, this, beanInstance);
+         InjectionPoint injectionPoint = new InjectionPointImpl(field, this);
          Object puInstance = manager.getEjbResolver().resolvePersistenceContext(injectionPoint, manager.getNaming());
          field.inject(beanInstance, puInstance);
       }
 
       for (AnnotatedMethod<?> method : annotatedItem.getAnnotatedMethods(manager.getEjbResolver().getPersistenceContextAnnotation()))
       {
-         InjectionPoint injectionPoint = new InjectionPointImpl(method, this, beanInstance);
+         InjectionPoint injectionPoint = new InjectionPointImpl(method, this);
          Object puInstance = manager.getEjbResolver().resolvePersistenceContext(injectionPoint, manager.getNaming());
          method.invoke(beanInstance, puInstance);
       }
 
       for (AnnotatedField<?> field : annotatedItem.getAnnotatedFields(manager.getEjbResolver().getResourceAnnotation()))
       {
-         InjectionPoint injectionPoint = new InjectionPointImpl(field, this, beanInstance);
+         InjectionPoint injectionPoint = new InjectionPointImpl(field, this);
          Object resourceInstance = manager.getEjbResolver().resolveResource(injectionPoint, manager.getNaming());
          field.inject(beanInstance, resourceInstance);
       }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java	2009-01-12 16:32:43 UTC (rev 893)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/injection/InjectionPointProvider.java	2009-01-12 16:34:17 UTC (rev 894)
@@ -37,7 +37,6 @@
 public class InjectionPointProvider
 {
    private final Stack<Bean<?>> beans = new Stack<Bean<?>>();
-   private final Stack<Object> beanInstances = new Stack<Object>();
    private final Stack<AnnotatedMember<?, ? extends Member>> injectionPoints = new Stack<AnnotatedMember<?, ? extends Member>>();
 
    /**
@@ -50,31 +49,9 @@
    public void pushBean(Bean<?> currentBean)
    {
       beans.push(currentBean);
-      beanInstances.push(null);
    }
 
    /**
-    * Pushes the current bean instance that has been instantiated, but has not
-    * yet had any injection points initialized.
-    * 
-    * @param currentInstance The bean instance last instantiated
-    */
-   public void pushInstance(Object currentInstance)
-   {
-      // Replace the null instance (from pushing the bean) with this one
-      // on the top of the stack.
-      if (beanInstances.peek() == null)
-      {
-         popInstance();
-         beanInstances.push(currentInstance);
-      }
-      else
-      {
-         throw new java.lang.IllegalStateException("More bean instances pushed than there are beans");
-      }
-   }
-
-   /**
     * Pushes the current injection point member being processed.
     * 
     * @param injectedMember The metadata for the injection point member
@@ -90,24 +67,10 @@
     */
    public void popBean()
    {
-      if (!beanInstances.isEmpty() && beanInstances.size() == beans.size() && beanInstances.peek() == null)
-      {
-         // Pop the null instance since a real one was never pushed.
-         popInstance();
-      }
       beans.pop();
    }
 
    /**
-    * Pops the current instance from the stack. This should be called whenever
-    * all processing is complete for instantiating a bean.
-    */
-   public void popInstance()
-   {
-      beanInstances.pop();
-   }
-
-   /**
     * Pops the current injection point being processed. This should be called
     * once the injection point is bound.
     */
@@ -124,7 +87,7 @@
     */
    public InjectionPoint getPreviousInjectionPoint()
    {
-      return new InjectionPointImpl(getPreviousInjectionMember(), getPreviousBean(), getPreviousInstance());
+      return new InjectionPointImpl(getPreviousInjectionMember(), getPreviousBean());
    }
 
    /**
@@ -135,19 +98,13 @@
     */
    public InjectionPoint getCurrentInjectionPoint()
    {
-      return new InjectionPointImpl(getCurrentInjectionMember(), getCurrentBean(), getCurrentInstance());
+      return new InjectionPointImpl(getCurrentInjectionMember(), getCurrentBean());
    }
 
    protected Bean<?> getCurrentBean()
    {
       return beans.peek();
    }
-
-   protected Object getCurrentInstance()
-   {
-      return beanInstances.peek();
-   }
-
    protected AnnotatedMember<?, ? extends Member> getCurrentInjectionMember()
    {
       if (injectionPoints.size() > 0)
@@ -164,24 +121,6 @@
       return result;
    }
 
-   protected Object getPreviousInstance()
-   {
-      Object result = null;
-      if (beanInstances.size() < beans.size())
-      {
-         // Return top of stack since this is the previous instance when a
-         // constructor is being invoked with injection points
-         result = beanInstances.peek();
-      }
-      else
-      {
-         Object currentInstance = beanInstances.pop();
-         result = beanInstances.peek();
-         beanInstances.push(currentInstance);
-      }
-      return result;
-   }
-
    protected AnnotatedMember<?, ? extends Member> getPreviousInjectionMember()
    {
       AnnotatedMember<?, ? extends Member> result = null;




More information about the weld-commits mailing list