1 6 7 package org.jfox.ejb.handler; 8 9 import java.lang.reflect.Method ; 10 import java.util.Iterator ; 11 import javax.ejb.Handle ; 12 13 import org.jfox.ejb.Bucket; 14 import org.jfox.ejb.EJBHomeMethod; 15 import org.jfox.ejb.EJBObjectId; 16 import org.jfox.ejb.EJBObjectMethod; 17 import org.jfox.ejb.connector.EJBInvocation; 18 19 24 25 public class B5_EJBOperationHandler extends AbstractHandler { 26 27 public Object invokeHome(Bucket bucket, EJBInvocation invocation, Iterator iter) throws Exception { 28 Method method = invocation.getMethod(); 30 if(method.equals(EJBHomeMethod.GetEJBMetaData)) { 31 return bucket.getEJBMetaData(); 32 } 33 else if(method.equals(EJBHomeMethod.GetHomeHandle)) { 34 return bucket.getHomeHandle(); 36 } 37 else if(method.equals(EJBHomeMethod.RemoveByHandle)) { 38 bucket.remove((Handle ) (invocation.getArgs()[0])); 39 return null; 40 } 42 else if(method.equals(EJBHomeMethod.RemoveByPrimaryKey)) { 43 bucket.remove(invocation.getArgs()[0]); 44 return null; 45 } 46 return super.invokeHome(bucket, invocation, iter); 47 } 48 49 public Object invokeBean(Bucket bucket, EJBInvocation invocation, Iterator iter) throws Exception { 50 Method method = invocation.getMethod(); 51 if(method.equals(EJBObjectMethod.GetEJBHome)) { 52 return bucket.getEJBHome(); 53 } 54 else if(method.equals(EJBObjectMethod.GetHandle)) { 55 return bucket.getHandle(invocation.getBean()); 56 } 57 else if(method.equals(EJBObjectMethod.GetPrimaryKey)) { 58 return bucket.getPrimaryKey(invocation.getBean()); 59 } 60 else if(method.equals(EJBObjectMethod.IsIdentical)) { 61 return new Boolean (bucket.isIdentical((EJBObjectId)invocation.getObjectId(), (EJBObjectId) invocation.getArgs()[0])); 63 } 64 return super.invokeBean(bucket, invocation, iter); 65 } 66 67 public static void main(String [] args) { 68 69 } 70 } | Popular Tags |