You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by co...@apache.org on 2010/08/19 18:59:40 UTC

svn commit: r987232 - /openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java

Author: covener
Date: Thu Aug 19 16:59:40 2010
New Revision: 987232

URL: http://svn.apache.org/viewvc?rev=987232&view=rev
Log:
[OWB-443] factor out the mechanism for removing the underlying EJB instance so it 
can be easily overriden from a subclass of BaseEJBBean.


Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.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=987232&r1=987231&r2=987232&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 Thu Aug 19 16:59:40 2010
@@ -129,15 +129,7 @@ public abstract class BaseEjbBean<T> ext
                     Object ejbInstance = getDependentSFSBForProxy(instance);
                     if (ejbInstance != null)
                     {
-                        List<Method> methods = getRemoveMethods();
-                        if (methods.size() > 0)
-                        {
-                            // FIXME: This needs to call an API from the EJB
-                            // container to remove the EJB instance directly,
-                            // not via a remove method.  For now, just call 1 
-                            // remove method directly on the EJB
-                            ClassUtil.callInstanceMethod(methods.get(0), ejbInstance, ClassUtil.OBJECT_EMPTY);
-                        }
+                        destroyStatefulSessionBeanInstance(instance, ejbInstance);
                     }
                 }
                 finally
@@ -152,21 +144,30 @@ public abstract class BaseEjbBean<T> ext
                 Object ejbInstance = webbeansContext.get(this);
                 if (ejbInstance != null)
                 {
-                    List<Method> methods = getRemoveMethods();
-                    if (methods.size() > 0) 
-                    {   
-                        // FIXME: This needs to call an API from the EJB
-                        // container to remove the EJB instance directly,
-                        // not via a remove method.  For now, just call 1 
-                        // remove method directly on the EJB
-                        ClassUtil.callInstanceMethod(methods.get(0), ejbInstance, ClassUtil.OBJECT_EMPTY);
-                    }
+                    destroyStatefulSessionBeanInstance(instance, ejbInstance);
                 }
             }
         }
     }
 
+    /**
+     * Called when we must ask the container to remove a specific
+     * @param proxyInstance The contextual reference 
+     * @param ejbInstance The underlying EJB instance to be removed
+     */
     
+    protected void destroyStatefulSessionBeanInstance(T proxyInstance, Object ejbInstance)
+    {
+        List<Method> methods = getRemoveMethods();
+        if (methods.size() > 0) 
+        {   
+            // FIXME: This needs to call an API from the EJB
+            // container to remove the EJB instance directly,
+            // not via a remove method.  For now, just call 1 
+            // remove method directly on the EJB
+            ClassUtil.callInstanceMethod(methods.get(0), ejbInstance, ClassUtil.OBJECT_EMPTY);
+        }
+    }
     /**
      * Subclasses can override this.
      * @return remove methods