1 45 package org.openejb.client; 46 47 import java.lang.reflect.Method ; 48 import java.rmi.RemoteException ; 49 50 55 public class StatefulEJBObjectHandler extends EJBObjectHandler { 56 57 public StatefulEJBObjectHandler() { 58 } 59 60 public StatefulEJBObjectHandler(EJBMetaDataImpl ejb, ServerMetaData server, ClientMetaData client){ 61 super(ejb, server, client); 62 } 63 64 public StatefulEJBObjectHandler(EJBMetaDataImpl ejb, ServerMetaData server, ClientMetaData client, Object primaryKey){ 65 super(ejb, server, client, primaryKey); 66 registerHandler( primaryKey, this ); 67 } 68 69 public Object getRegistryId() { 70 return primaryKey; 71 } 72 73 74 88 protected Object getPrimaryKey(Method method, Object [] args, Object proxy) throws Throwable { 89 throw new RemoteException ("Session objects are private resources and do not have primary keys"); 90 } 91 92 127 protected Object isIdentical(Method method, Object [] args, Object proxy) throws Throwable { 128 if ( args[0] == null ) return Boolean.FALSE; 129 130 EJBObjectProxy ejbObject = (EJBObjectProxy)args[0]; 131 EJBObjectHandler that = ejbObject.getEJBObjectHandler(); 132 133 return new Boolean (this.primaryKey.equals(that.primaryKey)); 134 } 135 136 protected Object remove(Method method, Object [] args, Object proxy) throws Throwable { 137 138 EJBRequest req = new EJBRequest( EJB_OBJECT_REMOVE ); 139 req.setClientIdentity( client.getClientIdentity() ); 140 req.setDeploymentCode( ejb.deploymentCode ); 141 req.setDeploymentId( ejb.deploymentID ); 142 req.setMethodInstance( method ); 143 req.setMethodParameters( args ); 144 req.setPrimaryKey( primaryKey ); 145 146 EJBResponse res = request( req ); 147 148 if ( EJB_ERROR == res.getResponseCode() ) { 149 throw (Throwable )res.getResult(); 150 } 151 152 invalidateAllHandlers( this.getRegistryId() ); 153 this.invalidateReference(); 154 return null; 155 } 156 157 } 158 | Popular Tags |