1 22 package org.jboss.ejb3.stateful; 23 24 import java.io.Externalizable ; 25 import java.io.ObjectInput ; 26 import java.io.IOException ; 27 import java.io.ObjectOutput ; 28 import org.jboss.ejb3.Ejb3Registry; 29 30 36 public class StatefulBeanContextReference implements Externalizable 37 { 38 private transient StatefulBeanContext beanContext; 39 private Object oid; 40 private String containerId; 41 42 43 44 public StatefulBeanContextReference() 45 { 46 } 47 48 public StatefulBeanContextReference(StatefulBeanContext beanContext) 49 { 50 this.beanContext = beanContext; 51 oid = beanContext.getId(); 52 containerId = beanContext.getContainer().getObjectName().getCanonicalName(); 53 } 54 55 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException 56 { 57 containerId = in.readUTF(); 58 oid = in.readObject(); 59 } 60 61 public void writeExternal(ObjectOutput out) throws IOException 62 { 63 out.writeUTF(containerId); 64 out.writeObject(oid); 65 } 66 67 public StatefulBeanContext getBeanContext() 68 { 69 if (beanContext == null) 70 { 71 StatefulContainer container = (StatefulContainer)Ejb3Registry.getContainer(containerId); 72 beanContext = container.getCache().get(oid); 73 } 74 return beanContext; 75 } 76 } 77 | Popular Tags |