openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cove...@apache.org
Subject svn commit: r937525 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-impl/src/main/java/org/apache/webbeans/intercept/
Date Fri, 23 Apr 2010 21:24:56 GMT
Author: covener
Date: Fri Apr 23 21:24:55 2010
New Revision: 937525

URL: http://svn.apache.org/viewvc?rev=937525&view=rev
Log:
[OWB-361] JSR299 intercetpors have to run in the same stack as the underlying bean method,

or they'd not be able to intercept a return value.


Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java?rev=937525&r1=937524&r2=937525&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
Fri Apr 23 21:24:55 2010
@@ -125,13 +125,14 @@ public class OpenWebBeansEjbInterceptor
     
     /**
      * Called for every business methods.
-     * @param context invocation context
+     * @param ejbContext invocation context
      * @return instance
      * @throws Exception
      */
     @AroundInvoke
-    public Object callToOwbInterceptors(InvocationContext context) throws Exception
+    public Object callToOwbInterceptors(InvocationContext ejbContext) throws Exception
     {
+        Object rv = null;
         boolean requestCreated = false;
         boolean applicationCreated = false;
         boolean requestAlreadyActive = false;
@@ -161,12 +162,12 @@ public class OpenWebBeansEjbInterceptor
             if(threadLocal.get() != null)
             {
                 //Calls OWB interceptors and decorators
-                callInterceptorsAndDecorators(context.getMethod(), context.getTarget(), context.getParameters());
   
+                rv = callInterceptorsAndDecorators(ejbContext.getMethod(), ejbContext.getTarget(),
ejbContext.getParameters(), ejbContext);    
             }
             else
             {
                 //Call OWB interceptors
-                callInterceptorsForNonContextuals(context.getMethod(), context.getTarget(),
context.getParameters());
+                rv = callInterceptorsForNonContextuals(ejbContext.getMethod(), ejbContext.getTarget(),
ejbContext.getParameters(), ejbContext);
             }
             
         }finally
@@ -181,7 +182,7 @@ public class OpenWebBeansEjbInterceptor
             }
         }
         
-        return context.proceed();
+        return rv;
     }
     
     /**
@@ -341,7 +342,7 @@ public class OpenWebBeansEjbInterceptor
      * @return result of operation
      * @throws Exception for any exception
      */    
-    private Object callInterceptorsForNonContextuals(Method method, Object instance, Object[]
arguments) throws Exception
+    private Object callInterceptorsForNonContextuals(Method method, Object instance, Object[]
arguments, InvocationContext ejbContext) throws Exception
     {
         BeanManagerImpl manager = BeanManagerImpl.getManager();
         
@@ -372,7 +373,7 @@ public class OpenWebBeansEjbInterceptor
         else
         {
             CreationalContext<?> cc = manager.createCreationalContext(null);
-            return runInterceptorStack(ejbBean.getInterceptorStack(), method, instance, arguments,
ejbBean, cc);
+            return runInterceptorStack(ejbBean.getInterceptorStack(), method, instance, arguments,
ejbBean, cc, ejbContext);
         }
         
         return null;
@@ -386,7 +387,7 @@ public class OpenWebBeansEjbInterceptor
      * @return result of operation
      * @throws Exception for any exception
      */
-    private Object callInterceptorsAndDecorators(Method method, Object instance, Object[]
arguments) throws Exception
+    private Object callInterceptorsAndDecorators(Method method, Object instance, Object[]
arguments, InvocationContext ejbContext) throws Exception
     {
         InjectionTargetBean<?> injectionTarget = (InjectionTargetBean<?>) threadLocal.get();
         
@@ -453,7 +454,7 @@ public class OpenWebBeansEjbInterceptor
                 if (WebBeansUtil.isContainsInterceptorMethod(this.interceptedMethodMap.get(method),
InterceptorType.AROUND_INVOKE))
                 {
                      return InterceptorUtil.callAroundInvokes(threadLocal.get(), instance,
(CreationalContextImpl<?>)threadLocalCreationalContext.get(), method, 
-                            arguments, InterceptorUtil.getInterceptorMethods(this.interceptedMethodMap.get(method),
InterceptorType.AROUND_INVOKE));
+                            arguments, InterceptorUtil.getInterceptorMethods(this.interceptedMethodMap.get(method),
InterceptorType.AROUND_INVOKE), ejbContext);
                 }
                 
             }
@@ -470,7 +471,7 @@ public class OpenWebBeansEjbInterceptor
     }
     
     private Object runInterceptorStack(List<InterceptorData> interceptorStack, Method
method, Object instance, 
-                                        Object[] arguments, BaseEjbBean<?> bean, CreationalContext<?>
creationalContext) throws Exception
+                                        Object[] arguments, BaseEjbBean<?> bean, CreationalContext<?>
creationalContext, InvocationContext ejbContext) throws Exception
     {
         if (interceptorStack.size() > 0)
         {
@@ -488,7 +489,8 @@ public class OpenWebBeansEjbInterceptor
             if (WebBeansUtil.isContainsInterceptorMethod(this.nonCtxInterceptedMethodMap.get(method),
InterceptorType.AROUND_INVOKE))
             {
                  return InterceptorUtil.callAroundInvokes(bean, instance, (CreationalContextImpl<?>)creationalContext,
method, 
-                        arguments, InterceptorUtil.getInterceptorMethods(this.nonCtxInterceptedMethodMap.get(method),
InterceptorType.AROUND_INVOKE));
+                        arguments, InterceptorUtil.getInterceptorMethods(this.nonCtxInterceptedMethodMap.get(method),
InterceptorType.AROUND_INVOKE),
+                        ejbContext);
             }
             
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java?rev=937525&r1=937524&r2=937525&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
Fri Apr 23 21:24:55 2010
@@ -523,14 +523,18 @@ public final class InterceptorUtil
     }
     
     public static Object callAroundInvokes(InjectionTargetBean<?> bean,Object instance,
CreationalContextImpl<?> creationalContext,
-            Method proceed, Object[] arguments, List<InterceptorData> stack) throws
Exception
+            Method proceed, Object[] arguments, List<InterceptorData> stack, InvocationContext
ejbInvocationContext) throws Exception
     {
         InvocationContextImpl impl = new InvocationContextImpl(bean, instance,
                                                                proceed, arguments, stack,
InterceptorType.AROUND_INVOKE);
+        if (ejbInvocationContext != null) 
+        {
+            impl.setEJBInvocationContext(ejbInvocationContext);
+        }
+        
         impl.setCreationalContext(creationalContext);
-
+        
         return impl.proceed();
-
     }
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java?rev=937525&r1=937524&r2=937525&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java
Fri Apr 23 21:24:55 2010
@@ -61,6 +61,7 @@ public class InvocationContextImpl imple
     private CreationalContext<?> creationalContext;
     
     private OwbBean<?> owbBean;
+    private InvocationContext ejbInvocationContext;
     
     /**
      * Initializes the context.
@@ -98,6 +99,15 @@ public class InvocationContextImpl imple
         this.creationalContext = ownerCreationalContext;
     }
 
+    /**
+     * Sets EJB invocation context
+     * @param c EJB containers invocation context
+     */
+    public void setEJBInvocationContext(InvocationContext c)
+    {
+        this.ejbInvocationContext = c;
+    }
+
     
     /**
      * Gets target instance for given bean.
@@ -235,6 +245,13 @@ public class InvocationContextImpl imple
                     SecurityUtil.doPrivilegedSetAccessible(method, false);
                 }                
             }
+            else 
+            { 
+                if (this.ejbInvocationContext != null)
+                {
+                    result = ejbInvocationContext.proceed();
+                }
+            }
         }
 
         return result;



Mime
View raw message