1 45 package org.openejb.client; 46 47 import java.lang.reflect.Method ; 48 import java.rmi.RemoteException ; 49 50 59 public class StatefulEJBHomeHandler extends EJBHomeHandler { 60 61 public StatefulEJBHomeHandler(){ 62 } 63 64 public StatefulEJBHomeHandler(EJBMetaDataImpl ejb, ServerMetaData server, ClientMetaData client){ 65 super(ejb, server, client); 66 } 67 68 80 protected Object findX(Method method, Object [] args, Object proxy) throws Throwable { 81 throw new UnsupportedOperationException ("Stateful beans may not have find methods"); 82 } 83 84 113 protected Object removeByPrimaryKey(Method method, Object [] args, Object proxy) throws Throwable { 114 throw new RemoteException ("Session objects are private resources and do not have primary keys"); 115 } 116 142 protected Object removeWithHandle(Method method, Object [] args, Object proxy) throws Throwable { 143 EJBObjectHandle handle = (EJBObjectHandle)args[0]; 145 146 if ( handle == null ) throw new NullPointerException ("The handle is null"); 148 149 EJBObjectHandler handler = handle.handler; 150 Object primKey = handler.primaryKey; 151 152 if ( !handler.ejb.deploymentID.equals(this.ejb.deploymentID) ){ 154 throw new IllegalArgumentException ("The handle is not from the same deployment"); 155 } 156 157 EJBRequest req = new EJBRequest( EJB_HOME_REMOVE_BY_HANDLE ); 158 req.setClientIdentity( client.getClientIdentity() ); 159 req.setDeploymentCode( handler.ejb.deploymentCode ); 160 req.setDeploymentId( handler.ejb.deploymentID ); 161 req.setMethodInstance( method ); 162 req.setMethodParameters( args ); 163 req.setPrimaryKey( primKey ); 164 165 EJBResponse res = request( req ); 166 167 if ( res.getResponseCode() == res.EJB_ERROR ) { 168 throw (Throwable )res.getResult(); 169 } 170 171 invalidateAllHandlers(handler.getRegistryId()); 172 handler.invalidateReference(); 173 return null; 174 } 175 } 176 | Popular Tags |