[jboss-cvs] JBossAS SVN: r60651 - branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 19 03:58:12 EST 2007


Author: bstansberry at jboss.com
Date: 2007-02-19 03:58:12 -0500 (Mon, 19 Feb 2007)
New Revision: 60651

Modified:
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
Log:
[EJBTHREE-867] Loosen coupling of lifecycle of nested SFSBs

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java	2007-02-19 08:57:46 UTC (rev 60650)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/NestedStatefulBeanContext.java	2007-02-19 08:58:12 UTC (rev 60651)
@@ -25,19 +25,26 @@
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.HashMap;
+import java.util.List;
+
 import javax.persistence.EntityManager;
 import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.ejb3.Ejb3Registry;
-import org.jboss.serial.io.MarshalledObject;
 
 /**
- * Comment
+ * Overrides superclass to not use MarshalledValue in externalization,
+ * as a nested context is meant to be serialized as part of its parent
+ * context and to share with it object references to any XPC or managed 
+ * entities.  Serializing with a MarshalledValue would result in separate
+ * deserializations of the XPCs and managed entities. 
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
 public class NestedStatefulBeanContext extends StatefulBeanContext
-{
+{   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 7835719320529968045L;
+
    public void writeExternal(ObjectOutput out) throws IOException
    {
       out.writeUTF(getContainer().getObjectName().getCanonicalName());
@@ -47,6 +54,10 @@
       out.writeObject(persistenceContexts);
       out.writeObject(interceptorInstances);
       out.writeObject(contains);
+      // Cannot write a ref to our parent as that seems to blow up serialization
+      //out.writeObject(containedIn);
+      out.writeBoolean(removed);
+      out.writeBoolean(replicationIsPassivation);
    }
 
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
@@ -57,7 +68,22 @@
       bean = in.readObject();
       persistenceContexts = (HashMap<String, EntityManager>)  in.readObject();
       interceptorInstances = (HashMap<Class, Object>)in.readObject();
-      beanMO = (MarshalledObject) in.readObject();
+      contains = (List<StatefulBeanContext>) in.readObject();
+      removed = in.readBoolean();
+      replicationIsPassivation = in.readBoolean();
+      
+      // Since we can't write a ref to our parent, our children also
+      // don't have a ref to use.  So reestablish it.
+      if (contains != null)
+      {
+         for (StatefulBeanContext contained : contains)
+         {
+            contained.containedIn = this;
+         }
+      }
+      
+      // If we've just been deserialized, we are passivated
+      passivated = true;
    }
 
 }




More information about the jboss-cvs-commits mailing list