package org.jfox.ejb.plugin;
import java.util.Iterator;
import javax.ejb.EnterpriseBean;
import org.jfox.ejb.Bulk;
import org.jfox.ejb.Invocation;
import org.jfox.ejb.SessionBulk;
import org.jfox.ejb.EJBPoolableObject;
import org.jfox.ejb.EJBObjectMethod;
public class A5_PoolInvoker extends AbstractInvoker {
public Object invokeBean(Bulk bulk, Invocation invocation, Iterator iter) throws Exception {
EJBPoolableObject pobj = ((SessionBulk)bulk).retrieveBean(invocation.getObjectId());
EnterpriseBean bean = pobj.getBeanInstance();
invocation.setBean(bean);
if(invocation.getMethod().equals(EJBObjectMethod.Remove)){
bulk.remove(bean);
pobj = null;
return null;
}
try {
return super.invokeBean(bulk, invocation, iter);
}
finally {
((SessionBulk)bulk).restoreBean(invocation.getObjectId(), pobj);
}
}
public static void main(String[] args) {
}
}