1 45 package org.openejb.client; 46 47 import java.lang.reflect.Method ; 48 import java.rmi.RemoteException ; 49 50 59 public class EntityEJBObjectHandler extends EJBObjectHandler { 60 61 62 public EntityEJBObjectHandler(){ 63 } 64 65 public EntityEJBObjectHandler(EJBMetaDataImpl ejb, ServerMetaData server, ClientMetaData client){ 66 super(ejb, server, client); 67 } 68 69 public EntityEJBObjectHandler(EJBMetaDataImpl ejb, ServerMetaData server, ClientMetaData client, Object primaryKey){ 70 super(ejb, server, client, primaryKey); 71 registryId = ejb.deploymentID+":"+primaryKey; 72 registerHandler( registryId, this ); 73 } 74 75 76 87 public Object getRegistryId(){ 88 return registryId; 89 } 90 91 92 protected Object getPrimaryKey(Method method, Object [] args, Object proxy) throws Throwable { 93 return primaryKey; 94 } 95 96 106 protected Object isIdentical(Method method, Object [] args, Object proxy) throws Throwable { 107 if ( args[0] == null ) return Boolean.FALSE; 108 109 EJBObjectProxy ejbObject = (EJBObjectProxy)args[0]; 110 EJBObjectHandler that = ejbObject.getEJBObjectHandler(); 111 112 return new Boolean (this.registryId.equals(that.registryId)); 113 114 } 115 116 protected Object remove(Method method, Object [] args, Object proxy) throws Throwable { 117 118 EJBRequest req = new EJBRequest( EJB_OBJECT_REMOVE ); 119 120 req.setMethodParameters( args ); 121 req.setMethodInstance( method ); 122 req.setClientIdentity( client.getClientIdentity() ); 123 req.setDeploymentCode( ejb.deploymentCode ); 124 req.setDeploymentId( ejb.deploymentID ); 125 req.setPrimaryKey( primaryKey ); 126 127 EJBResponse res = request( req ); 128 129 switch (res.getResponseCode()) { 130 case EJB_ERROR: 131 throw (Throwable )res.getResult(); 132 case EJB_SYS_EXCEPTION: 133 throw (Throwable )res.getResult(); 134 case EJB_APP_EXCEPTION: 135 throw (Throwable )res.getResult(); 136 case EJB_OK: 137 invalidateAllHandlers(getRegistryId()); 138 return null; 139 default: 140 throw new RemoteException ("Received invalid response code from server: "+res.getResponseCode()); 141 } 142 } 143 144 } 145 | Popular Tags |