public Object invokeHome(Invocation mi)
throws Exception
{
// Get context
EntityContainer ec = (EntityContainer) getContainer();
EntityEnterpriseContext ctx = (EntityEnterpriseContext) ec.getInstancePool().get();
// Pass it to the method invocation
mi.setEnterpriseContext(ctx);
// Give it the transaction
ctx.setTransaction(mi.getTransaction());
// Set the current security information
ctx.setPrincipal(mi.getPrincipal());
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME);
Object result;
try
{
// Invoke through interceptors
result = getNext().invokeHome(mi);
}
finally
{
AllowedOperationsAssociation.popInMethodFlag();
}
// No id, means we can put the context back in the pool
if (ctx.getId() == null)
{
ctx.setTransaction(null);
ec.getInstancePool().free(ctx);
}
// We are done
return result;
}