package org.jfox.ejb.plugin;
import java.util.Iterator;
import java.lang.reflect.Method;
import javax.ejb.Handle;
import org.jfox.ejb.Invocation;
import org.jfox.ejb.Bulk;
import org.jfox.ejb.EJBHomeMethod;
import org.jfox.ejb.EJBObjectMethod;
import org.jfox.ejb.ObjectId;
public class B5_EJBOperationInvoker extends AbstractInvoker{
public Object invokeHome(Bulk bulk, Invocation invocation, Iterator iter) throws Exception {
Method method = invocation.getMethod();
if(method.equals(EJBHomeMethod.GetEJBMetaData)){
return bulk.getEJBMetaData();
}
else if(method.equals(EJBHomeMethod.GetHomeHandle)){
return bulk.getHomeHandle();
}
else if(method.equals(EJBHomeMethod.RemoveByHandle)){
bulk.remove((Handle)(invocation.getArgs()[0]));
return null;
}
else if(method.equals(EJBHomeMethod.RemoveByPrimaryKey)){
bulk.remove(invocation.getArgs()[0]);
return null;
}
return super.invokeHome(bulk, invocation, iter);
}
public Object invokeBean(Bulk bulk, Invocation invocation, Iterator iter) throws Exception {
Method method = invocation.getMethod();
if(method.equals(EJBObjectMethod.GetEJBHome)) {
return bulk.getEJBHome();
}
else if(method.equals(EJBObjectMethod.GetHandle)){
return bulk.getHandle(invocation.getBean());
}
else if(method.equals(EJBObjectMethod.GetPrimaryKey)){
return bulk.getPrimaryKey(invocation.getBean());
}
else if(method.equals(EJBObjectMethod.IsIdentical)){
return new Boolean(bulk.isIdentical(invocation.getObjectId(),(ObjectId)invocation.getArgs()[0]));
}
return super.invokeBean(bulk, invocation, iter);
}
public static void main(String[] args) {
}
}