Author: covener
Date: Sat Sep  4 18:48:40 2010
New Revision: 992657

URL: http://svn.apache.org/viewvc?rev=992657&view=rev
Log:
Allow callers to ask InvocationContextImpl to use a key, other than the target
instance, into the eventual DependentCreationalContext.  

This helps with EJB passivation, as we currently end up with references to
the underlying EJB instance (unnecessarily) floating around in the dependent
creational context.


Modified:
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java

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=992657&r1=992656&r2=992657&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
 Sat Sep  4 18:48:40 2010
@@ -68,6 +68,9 @@ public class InvocationContextImpl imple
     private OwbBean<?> owbBean;
     private InvocationContext ejbInvocationContext;
     
+    /** alternate key to be used for dependent creational contexts */
+    private Object ccKey;
+    
     /**
      * Initializes the context.
      * 
@@ -216,7 +219,8 @@ public class InvocationContextImpl imple
                 SecurityUtil.doPrivilegedSetAccessible(method, true);
             }
             
-            Object t = 
intc.createNewInstance(this.target,(CreationalContextImpl<?>)this.creationalContext);
+            Object t = intc.createNewInstance(this.ccKey != null ? this.ccKey 
: this.target,
+                    (CreationalContextImpl<?>)this.creationalContext);     
             
             if (t == null)
             {
@@ -295,7 +299,8 @@ public class InvocationContextImpl imple
 
             currentMethod++;
 
-            Object t = 
intc.createNewInstance(this.target,(CreationalContextImpl<?>)this.creationalContext);
+            Object t = intc.createNewInstance(this.ccKey != null ? this.ccKey 
: this.target,
+                    (CreationalContextImpl<?>)this.creationalContext);      
             
             //In bean class
             if (t == null)
@@ -389,4 +394,15 @@ public class InvocationContextImpl imple
         // TODO Auto-generated method stub
         return null;
     }    
+    
+    /**
+     * Sets the alternate key (alternate owner instance) to be used within 
+     * the passed CreationalContext for dependent interceptors.
+     * 
+     * @param ccKey a unique key used to index dependent interceptors
+     */
+    public void setCcKey(Object ccKey)
+    {
+        this.ccKey = ccKey;
+    }
 }
\ No newline at end of file


Reply via email to