openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r933493 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept: ApplicationScopedBeanIntereptorHandler.java DependentScopedBeanInterceptorHandler.java InterceptorHandler.java NormalScopedBeanInterceptorHandler.java
Date Tue, 13 Apr 2010 06:42:01 GMT
Author: struberg
Date: Tue Apr 13 06:42:01 2010
New Revision: 933493

URL: http://svn.apache.org/viewvc?rev=933493&view=rev
Log:
OWB-351 revert changes from r933348 since they re-introduce concurrency problems

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java?rev=933493&r1=933492&r2=933493&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/ApplicationScopedBeanIntereptorHandler.java
Tue Apr 13 06:42:01 2010
@@ -21,6 +21,7 @@ package org.apache.webbeans.intercept;
 import javax.enterprise.context.spi.CreationalContext;
 
 import org.apache.webbeans.component.OwbBean;
+import org.apache.webbeans.context.creational.CreationalContextImpl;
 
 
 /**
@@ -42,7 +43,7 @@ public class ApplicationScopedBeanIntere
     /**
      * Creates a new handler.
      * @param bean bean
-     * @param creationalContext creaitonal context
+     * @param creationalContext creational context
      */
     public ApplicationScopedBeanIntereptorHandler(OwbBean<?> bean, CreationalContext<?>
creationalContext)
     {
@@ -52,11 +53,11 @@ public class ApplicationScopedBeanIntere
     /**
      * {@inheritDoc}
      */
-    protected Object getContextualInstance(OwbBean<Object> bean)
+    protected Object getContextualInstance(OwbBean<Object> bean, CreationalContextImpl<?>
creationalContext)
     {
         if (cachedInstance == null) 
         {
-            cachedInstance = super.getContextualInstance(bean);
+            cachedInstance = super.getContextualInstance(bean, creationalContext);
         }
         
         return cachedInstance;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java?rev=933493&r1=933492&r2=933493&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/DependentScopedBeanInterceptorHandler.java
Tue Apr 13 06:42:01 2010
@@ -67,10 +67,12 @@ public class DependentScopedBeanIntercep
     /**
      * {@inheritDoc}
      */
-    protected Object callAroundInvokes(Method proceed, Object[] arguments, List<InterceptorData>
stack) throws Exception
+    protected Object callAroundInvokes(Method proceed, Object[] arguments, List<InterceptorData>
stack,
+                                       CreationalContextImpl<?> cc)
+    throws Exception
     {
         InvocationContextImpl impl = new InvocationContextImpl(this.bean, this.actualInstance
,proceed, arguments, stack, InterceptorType.AROUND_INVOKE);
-        impl.setCreationalContext(creationalContext);
+        impl.setCreationalContext(cc);
         
         return impl.proceed();
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java?rev=933493&r1=933492&r2=933493&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorHandler.java
Tue Apr 13 06:42:01 2010
@@ -169,11 +169,13 @@ public abstract class InterceptorHandler
      * @param method business method
      * @param proceed proceed method
      * @param arguments method arguments
-     * @param ownerCreationalContext bean creational context
+     * @param creationalContext bean creational context
      * @return method result
      * @throws Exception for exception
      */
-    public Object invoke(Object instance, Method method, Method proceed, Object[] arguments,
CreationalContextImpl<?> ownerCreationalContext) throws Exception
+    public Object invoke(Object instance, Method method, Method proceed, Object[] arguments,

+                         CreationalContextImpl<?> creationalContext)
+    throws Exception
     {
         //Result of invocation
         Object result = null;
@@ -210,7 +212,7 @@ public abstract class InterceptorHandler
                         ((ProxyObject)delegate).setHandler(this.delegateHandler);
 
                         // Gets component decorator stack
-                        decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget,
instance, delegate, ownerCreationalContext);                        
+                        decorators = WebBeansDecoratorConfig.getDecoratorStack(injectionTarget,
instance, delegate, creationalContext);                        
                         //Sets decorator stack of delegate
                         this.delegateHandler.setDecorators(decorators);
                         
@@ -247,7 +249,10 @@ public abstract class InterceptorHandler
                         // Call Around Invokes
                         if (WebBeansUtil.isContainsInterceptorMethod(this.interceptedMethodMap.get(method),
InterceptorType.AROUND_INVOKE))
                         {
-                            return callAroundInvokes(method, arguments, InterceptorUtil.getInterceptorMethods(this.interceptedMethodMap.get(method),
InterceptorType.AROUND_INVOKE));
+                            return callAroundInvokes(method, arguments, 
+                                                    InterceptorUtil.getInterceptorMethods(this.interceptedMethodMap.get(method),
+                                                                                        
 InterceptorType.AROUND_INVOKE),
+                                                    creationalContext);
                         }
                         
                     }
@@ -302,7 +307,9 @@ public abstract class InterceptorHandler
      * @return return of method
      * @throws Exception for any exception
      */
-    protected abstract Object callAroundInvokes(Method interceptedMethod, Object[] arguments,
List<InterceptorData> stack) throws Exception;
+    protected abstract Object callAroundInvokes(Method interceptedMethod, Object[] arguments,

+                                                List<InterceptorData> stack, CreationalContextImpl<?>
creationalContext)
+    throws Exception;
     
     /**
      * 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java?rev=933493&r1=933492&r2=933493&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/NormalScopedBeanInterceptorHandler.java
Tue Apr 13 06:42:01 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.webbeans.intercept;
 
-import java.lang.ref.WeakReference;
 import java.lang.reflect.Method;
 import java.util.List;
 
@@ -43,9 +42,6 @@ public class NormalScopedBeanInterceptor
     /**Serial id*/
     private static final long serialVersionUID = 1L;
     
-    /**Creational context*/
-    private transient WeakReference<CreationalContext<?>> creationalContext =
null;
-
     /**
      * Creates a new bean instance
      * @param bean bean 
@@ -54,7 +50,6 @@ public class NormalScopedBeanInterceptor
     public NormalScopedBeanInterceptorHandler(OwbBean<?> bean, CreationalContext<?>
creationalContext)
     {
         super(bean);
-        this.creationalContext = new WeakReference<CreationalContext<?>>(creationalContext);
     }
     
     /**
@@ -63,21 +58,38 @@ public class NormalScopedBeanInterceptor
     @Override
     public Object invoke(Object instance, Method method, Method proceed, Object[] arguments)
throws Exception
     {
+        CreationalContextImpl<?> creationalContext = null;
+        
+        //Context of the bean
+        Context webbeansContext = getBeanManager().getContext(bean.getScope());
+
+        if (webbeansContext instanceof AbstractContext)
+        {
+            creationalContext = (CreationalContextImpl<?>) ((AbstractContext)webbeansContext).getCreationalContext(bean);
+        }
+        if (creationalContext == null)
+        {
+            // if there was no CreationalContext set from external, we create a new one
+            creationalContext = (CreationalContextImpl<?>) CreationalContextFactory.getInstance().getCreationalContext(bean);
+        }
+        
         //Get instance from context
-        Object webbeansInstance = getContextualInstance((OwbBean<Object>) this.bean);
+        Object webbeansInstance = getContextualInstance((OwbBean<Object>) this.bean,
creationalContext);
         
         //Call super
-        return super.invoke(webbeansInstance, method, proceed, arguments, (CreationalContextImpl<?>)
this.creationalContext.get());
+        return super.invoke(webbeansInstance, method, proceed, arguments, creationalContext);
     }
         
     /**
      * {@inheritDoc}
      */
-    protected Object callAroundInvokes(Method proceed, Object[] arguments, List<InterceptorData>
stack) throws Exception
+    protected Object callAroundInvokes(Method proceed, Object[] arguments, List<InterceptorData>
stack, CreationalContextImpl<?> creationalContext)
+    throws Exception
     {
-        InvocationContextImpl impl = new InvocationContextImpl(this.bean, getContextualInstance((OwbBean<Object>)
this.bean),
+        InvocationContextImpl impl = new InvocationContextImpl(this.bean, 
+                                                               getContextualInstance((OwbBean<Object>)
this.bean, creationalContext),
                                                                proceed, arguments, stack,
InterceptorType.AROUND_INVOKE);
-        impl.setCreationalContext(creationalContext.get());
+        impl.setCreationalContext(creationalContext);
 
         return impl.proceed();
 
@@ -87,9 +99,10 @@ public class NormalScopedBeanInterceptor
     /**
      * Gets instance from context.
      * @param bean bean instance
+     * @param creationalContext
      * @return the underlying contextual instance, either cached or resolved from the context

      */
-    protected Object getContextualInstance(OwbBean<Object> bean)
+    protected Object getContextualInstance(OwbBean<Object> bean, CreationalContextImpl<?>
creationalContext)
     {
         Object webbeansInstance = null;
         
@@ -104,22 +117,8 @@ public class NormalScopedBeanInterceptor
             return webbeansInstance;
         }
         
-        if (webbeansContext instanceof AbstractContext)
-        {
-            CreationalContext<?> cc = ((AbstractContext)webbeansContext).getCreationalContext(bean);
-            if (cc != null)
-            {
-                creationalContext = new WeakReference<CreationalContext<?>>(cc);
-            }
-        }
-        if (creationalContext == null)
-        {
-            // if there was no CreationalContext set from external, we create a new one
-            creationalContext = new WeakReference<CreationalContext<?>>(CreationalContextFactory.getInstance().getCreationalContext(bean));
-        }
-        
         // finally, we create a new contextual instance
-        webbeansInstance = webbeansContext.get((Contextual<Object>)this.bean, (CreationalContext<Object>)
creationalContext.get());
+        webbeansInstance = webbeansContext.get((Contextual<Object>)this.bean, (CreationalContext<Object>)
creationalContext);
         
         return webbeansInstance;
     }



Mime
View raw message