You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by yi...@apache.org on 2010/10/28 06:32:39 UTC

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

Author: yingwang
Date: Thu Oct 28 04:32:39 2010
New Revision: 1028179

URL: http://svn.apache.org/viewvc?rev=1028179&view=rev
Log:
[owb-448] make EjbBeanProxyHandler serializable.

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=1028179&r1=1028178&r2=1028179&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 Oct 28 04:32:39 2010
@@ -18,9 +18,13 @@
  */
 package org.apache.webbeans.ejb.common.proxy;
 
+import java.io.Externalizable;
 import java.io.IOException;
+import java.io.ObjectInput;
 import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
 import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.List;
 
@@ -50,7 +54,7 @@ import javassist.util.proxy.MethodHandle
  *
  */
 @SuppressWarnings("unchecked")
-public class EjbBeanProxyHandler implements MethodHandler
+public class EjbBeanProxyHandler implements MethodHandler, Serializable, Externalizable
 {
     //Logger instance
     private final WebBeansLogger logger = WebBeansLogger.getLogger(EjbBeanProxyHandler.class);
@@ -67,6 +71,11 @@ public class EjbBeanProxyHandler impleme
     /**Creational Context*/
     private CreationalContext<?> creationalContext;
     
+    //DO NOT REMOVE, used by PASSIVATION.
+    public EjbBeanProxyHandler() 
+    {
+    }
+    
     /**
      * Creates a new instance.
      * @param ejbBean ejb bean instance
@@ -314,5 +323,45 @@ public class EjbBeanProxyHandler impleme
         this.creationalContext = (CreationalContext<?>)s.readObject();
         this.dependentEJB = s.readObject();
     }
+
+    @Override
+    public void writeExternal(ObjectOutput out) throws IOException 
+    {
+        // we have to write the ids for all beans, not only PassivationCapable
+        // since this gets serialized along with the Bean proxy.
+        String passivationId = this.ejbBean.getId();
+        if (passivationId!= null)
+        {
+            out.writeObject(passivationId);
+        }
+        else
+        {
+            out.writeObject(null);
+            
+            if(logger.wblWillLogWarn())
+            {
+                logger.warn(OWBLogConst.WARN_0015, this.ejbBean);   
+            }
+        }
+        
+        out.writeBoolean(this.isDependent);
+        out.writeObject(this.creationalContext);
+        out.writeObject(this.dependentEJB);
+    }
+
+    @Override
+    public void readExternal(ObjectInput in) throws IOException,
+            ClassNotFoundException 
+    {
+        String passivationId = (String) in.readObject();
+        if (passivationId != null)
+        {
+            this.ejbBean = (BaseEjbBean<?>)BeanManagerImpl.getManager().getPassivationCapableBean(passivationId);
+        }
+        
+        this.isDependent = in.readBoolean();
+        this.creationalContext = (CreationalContext<?>)in.readObject();
+        this.dependentEJB = in.readObject();
+    }
     
 }