openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1433702 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/portable/ webbeans-impl/src/m...
Date Tue, 15 Jan 2013 22:18:24 GMT
Author: arne
Date: Tue Jan 15 22:18:23 2013
New Revision: 1433702

URL: http://svn.apache.org/viewvc?rev=1433702&view=rev
Log:
OWB-755: Moved resource-injection into InjectionTargetImpl

Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.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/ExtensionBean.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/InterceptorBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java?rev=1433702&r1=1433701&r2=1433702&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
Tue Jan 15 22:18:23 2013
@@ -86,15 +86,6 @@ public abstract class BaseEjbBean<T> ext
         
         return false;
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected T createComponentInstance(CreationalContext<T> creationalContext)
-    {
-        return getInjectionTarget().produce(creationalContext);
-    }
     
     /**
      * {@inheritDoc}

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=1433702&r1=1433701&r2=1433702&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
Tue Jan 15 22:18:23 2013
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.ejb.common.component;
 
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
 import java.util.List;
 import java.util.Set;
 
@@ -78,11 +80,14 @@ public abstract class EjbBeanBuilder<T, 
     }
 
     @Override
-    protected InjectionTarget<T> buildInjectionTarget(AnnotatedType<T> annotatedType,
+    protected InjectionTarget<T> buildInjectionTarget(Set<Type> types,
+                                                      Set<Annotation> qualifiers,
+                                                      AnnotatedType<T> annotatedType,
                                                       Set<InjectionPoint> points,
                                                       WebBeansContext webBeansContext,
                                                       List<AnnotatedMethod<?>>
postConstructMethods,
                                                       List<AnnotatedMethod<?>>
preDestroyMethods)
+
     {
         return new AbstractEjbInjectionTarget<T>(annotatedType, points, webBeansContext)
         {

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=1433702&r1=1433701&r2=1433702&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
Tue Jan 15 22:18:23 2013
@@ -60,15 +60,6 @@ public class ExtensionBean<T> extends In
      * {@inheritDoc}
      */
     @Override
-    protected T createComponentInstance(CreationalContext<T> creationalContext)
-    {
-        return getInjectionTarget().produce(creationalContext);
-    }
-    
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     protected void destroyComponentInstance(T instance, CreationalContext<T> creationalContext)
     {
         

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=1433702&r1=1433701&r2=1433702&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
Tue Jan 15 22:18:23 2013
@@ -124,7 +124,7 @@ public abstract class InjectionTargetBea
     protected T createInstance(CreationalContext<T> creationalContext)
     {
         //Create actual bean instance
-        T instance = createComponentInstance(creationalContext);
+        T instance = getInjectionTarget().produce(creationalContext);
 
         //X TODO this should not be needed finally!
         //For dependent instance checks
@@ -138,7 +138,6 @@ public abstract class InjectionTargetBea
                 //This is a dependent scoped bean instance,
                 //Therefore we inject dependencies of this instance
                 //Otherwise we loose injection
-                injectResources(instance, creationalContext);
                 getInjectionTarget().inject(instance, creationalContext);
 
                 //Dependent proxy
@@ -146,9 +145,6 @@ public abstract class InjectionTargetBea
             }
         }
 
-        //Inject resources
-        injectResources(instance, creationalContext);
-
         getInjectionTarget().inject(instance, creationalContext);
 
         //Post construct
@@ -171,17 +167,6 @@ public abstract class InjectionTargetBea
     }
 
     /**
-     * Sub-classes must override this method to create bean instance.
-     * 
-     * @param creationalContext creational context
-     * @return bean instance
-     */
-    protected T createComponentInstance(CreationalContext<T> creationalContext)
-    {
-        return null;
-    }
-
-    /**
      * Sub-classes must override this method to destroy bean instance.
      * 
      * @param instance object instance.
@@ -228,40 +213,6 @@ public abstract class InjectionTargetBea
             }            
         }
     }
-    
-    /**
-     * {@inheritDoc}
-     */
-    public void injectResources(T instance, CreationalContext<T> creationalContext)
-    {
-        if(getWebBeansType().equals(WebBeansType.MANAGED))
-        {
-            try
-            {
-                ResourceInjectionService service = null;
-                try
-                {
-                    service = getWebBeansContext().getService(ResourceInjectionService.class);
-                    
-                }
-                catch(Exception e)
-                {
-                    // When running in tests
-                }
-                
-                if(service != null)
-                {
-                    service.injectJavaEEResources(instance);   
-                }
-            }
-            catch (Exception e)
-            {
-                getLogger().log(Level.SEVERE, OWBLogConst.ERROR_0023, instance);
-                throw new WebBeansException(MessageFormat.format(
-                        WebBeansLoggerFacade.getTokenString(OWBLogConst.ERROR_0023), instance),
e);
-            }
-        }
-    }
 
     /**
      * {@inheritDoc}

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=1433702&r1=1433701&r2=1433702&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
Tue Jan 15 22:18:23 2013
@@ -89,13 +89,6 @@ public abstract class InterceptorBean<T>
         }
     }
 
-    @Override
-    protected T createComponentInstance(CreationalContext<T> creationalContext)
-    {
-        return getInjectionTarget().produce(creationalContext);
-    }
-
-
     /**
      * Get constructor.
      *

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java?rev=1433702&r1=1433701&r2=1433702&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
Tue Jan 15 22:18:23 2013
@@ -70,15 +70,6 @@ public class ManagedBean<T> extends Inje
     }
 
     /**
-     * {@inheritDoc}
-     */
-    @Override
-    protected T createComponentInstance(CreationalContext<T> creationalContext)
-    {
-        return getInjectionTarget().produce(creationalContext);
-    }
-
-    /**
      * Get constructor.
      * 
      * @return constructor

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java?rev=1433702&r1=1433701&r2=1433702&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
Tue Jan 15 22:18:23 2013
@@ -24,12 +24,14 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
+import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.logging.Level;
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.event.Observes;
@@ -48,16 +50,20 @@ import javax.inject.Inject;
 import javax.interceptor.InvocationContext;
 
 import org.apache.webbeans.component.SelfInterceptorBean;
+import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
+import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.inject.InjectableConstructor;
 import org.apache.webbeans.inject.InjectableField;
 import org.apache.webbeans.inject.InjectableMethod;
 import org.apache.webbeans.intercept.DefaultInterceptorHandler;
 import org.apache.webbeans.intercept.LifecycleInterceptorInvocationContext;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory;
 import org.apache.webbeans.proxy.InterceptorHandler;
 import org.apache.webbeans.proxy.OwbInterceptorProxy;
+import org.apache.webbeans.spi.ResourceInjectionService;
 import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ExceptionUtil;
 
@@ -183,6 +189,7 @@ public class InjectionTargetImpl<T> exte
         injectFields(type, instance, context);
         injectMethods(type, instance, context);
         injectInitializerMethods(type, instance, context);
+        injectResources(instance);
     }
 
     private void injectFields(Class<?> type, T instance, CreationalContextImpl<T>
context)
@@ -233,6 +240,33 @@ public class InjectionTargetImpl<T> exte
             }
         }
     }
+    
+    private void injectResources(T instance)
+    {
+        try
+        {
+            ResourceInjectionService service = null;
+            try
+            {
+                service = webBeansContext.getService(ResourceInjectionService.class);
+            
+            }
+            catch (Exception e)
+            {
+                // When running in tests
+            }
+        
+            if (service != null)
+            {
+                service.injectJavaEEResources(instance);   
+            }
+        }
+        catch (Exception e)
+        {
+            throw new WebBeansException(MessageFormat.format(
+                WebBeansLoggerFacade.getTokenString(OWBLogConst.ERROR_0023), instance), e);
+        }
+    }
 
     @Override
     public void postConstruct(final T instance)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java?rev=1433702&r1=1433701&r2=1433702&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/creation/InjectionTargetProducerRemove.java
Tue Jan 15 22:18:23 2013
@@ -103,7 +103,6 @@ public class InjectionTargetProducerRemo
                     return;
                 }
                 
-                bean.injectResources(instance, ctx);
                 bean.getInjectionTarget().inject(instance, ctx);
             }
         }



Mime
View raw message