openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cove...@apache.org
Subject svn commit: r966659 - /openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy/EjbBeanProxyHandler.java
Date Thu, 22 Jul 2010 13:54:30 GMT
Author: covener
Date: Thu Jul 22 13:54:29 2010
New Revision: 966659

URL: http://svn.apache.org/viewvc?rev=966659&view=rev
Log:
[OWB-415] save dependent scoped EJB's in the MethodHandler. The EJBBeanProxyHandler has to
act like
both the Dependent and Normal scoped interceptor handlers.


Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy/EjbBeanProxyHandler.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy/EjbBeanProxyHandler.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy/EjbBeanProxyHandler.java?rev=966659&r1=966658&r2=966659&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy/EjbBeanProxyHandler.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/proxy/EjbBeanProxyHandler.java
Thu Jul 22 13:54:29 2010
@@ -58,6 +58,9 @@ public class EjbBeanProxyHandler impleme
     /**Proxy ejb bean instance*/
     private BaseEjbBean<?> ejbBean;
     
+    private Object dependentEjb;
+    private boolean isDependent = false;
+    
     /**Creational Context*/
     private transient CreationalContext<?> creationalContext;
     
@@ -77,6 +80,12 @@ public class EjbBeanProxyHandler impleme
         {
             this.creationalContext = creationalContext;   
         }
+        
+        if (ejbBean.getScope().equals(Dependent.class)) 
+        {
+            isDependent = true;
+            dependentEjb = null;
+        }
     }    
     
     /**
@@ -126,27 +135,24 @@ public class EjbBeanProxyHandler impleme
             //Context of the bean
             Context webbeansContext = BeanManagerImpl.getManager().getContext(this.ejbBean.getScope());
             
-            //Already saved in context?
-            webbeansInstance=webbeansContext.get(this.ejbBean);
-            if (webbeansInstance != null)
-            {
-                boolean access = method.isAccessible();
-                SecurityUtil.doPrivilegedSetAccessible(method, true);
-                try
+            if (isDependent && this.dependentEjb != null) 
+            {
+                webbeansInstance = this.dependentEjb;
+            }
+            else 
+            {
+                // try looking in the context without getContextualCreationalContext() first
+                webbeansInstance = webbeansContext.get(this.ejbBean);
+                if (webbeansInstance == null)
                 {
-                    return method.invoke(webbeansInstance, arguments);
-                    
+                    webbeansInstance = webbeansContext.get((Contextual<Object>)this.ejbBean,
getContextualCreationalContext());
                 }
-                finally
+                if (isDependent)
                 {
-                    SecurityUtil.doPrivilegedSetAccessible(method, access);
-                }            
-                
+                    this.dependentEjb = webbeansInstance;
+                }
             }
             
-            // Getting actual EJB Bean proxy instance
-            webbeansInstance = webbeansContext.get((Contextual<Object>)this.ejbBean,
getContextualCreationalContext());
-            
             //Call actual method on proxy
             //Actually it is called from OWB Proxy --> EJB Proxy --> Actual Bean Instance
             boolean access = method.isAccessible();



Mime
View raw message