1 45 package org.openejb.client; 46 47 import java.io.IOException ; 48 import java.io.ObjectInput ; 49 import java.io.ObjectOutput ; 50 import java.rmi.RemoteException ; 51 52 import javax.ejb.EJBObject ; 53 54 73 public class EJBObjectHandle implements java.io.Externalizable , javax.ejb.Handle { 74 75 protected transient EJBObjectProxy ejbObjectProxy; 76 protected transient EJBObjectHandler handler; 77 78 79 public EJBObjectHandle() {} 80 81 public EJBObjectHandle(EJBObjectProxy proxy) { 82 this.ejbObjectProxy = proxy; 83 this.handler = ejbObjectProxy.getEJBObjectHandler(); 84 } 85 86 protected void setEJBObjectProxy(EJBObjectProxy ejbObjectProxy) { 87 this.ejbObjectProxy = ejbObjectProxy; 88 this.handler = ejbObjectProxy.getEJBObjectHandler(); 89 } 90 91 97 public EJBObject getEJBObject() throws RemoteException { 98 return ejbObjectProxy; 99 } 100 101 public void writeExternal(ObjectOutput out) throws IOException { 105 106 handler.client.writeExternal( out ); 108 109 EJBMetaDataImpl ejb = handler.ejb; 110 out.writeObject( ejb.homeClass ); 111 out.writeObject( ejb.remoteClass ); 112 out.writeObject( ejb.keyClass ); 113 out.writeByte( ejb.type ); 114 out.writeUTF( ejb.deploymentID ); 115 out.writeShort( ejb.deploymentCode ); 116 handler.server.writeExternal( out ); 117 out.writeObject( handler.primaryKey ); 118 } 119 120 126 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 127 ClientMetaData client = new ClientMetaData(); 128 EJBMetaDataImpl ejb = new EJBMetaDataImpl(); 129 ServerMetaData server = new ServerMetaData(); 130 131 client.readExternal( in ); 132 133 ejb.homeClass = (Class ) in.readObject(); 134 ejb.remoteClass = (Class ) in.readObject(); 135 ejb.keyClass = (Class ) in.readObject(); 136 ejb.type = in.readByte(); 137 ejb.deploymentID = in.readUTF(); 138 ejb.deploymentCode = in.readShort(); 139 140 server.readExternal( in ); 141 Object primaryKey = in.readObject(); 142 143 handler = EJBObjectHandler.createEJBObjectHandler(ejb, server, client, primaryKey); 144 ejbObjectProxy = handler.createEJBObjectProxy(); 145 } 146 147 } | Popular Tags |