public Object invoke(final Invocation mi) throws Exception
{
// Get context
InstancePool pool = container.getInstancePool();
StatelessSessionEnterpriseContext ctx = null;
try
{
ctx = (StatelessSessionEnterpriseContext) pool.get();
}
catch (EJBException e)
{
throw e;
}
catch (RemoteException e)
{
throw e;
}
catch (Exception e)
{
InvocationType type = mi.getType();
boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME);
if (isLocal)
throw new EJBException("Unable to get an instance from the pool", e);
else
throw new RemoteException("Unable to get an intance from the pool", e);
}
// Set the current security information
ctx.setPrincipal(mi.getPrincipal());
// Set the JACC EnterpriseBean PolicyContextHandler data
EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance());
// Use this context
mi.setEnterpriseContext(ctx);
// JAXRPC/JAXWS message context
Object msgContext = mi.getValue(InvocationKey.SOAP_MESSAGE_CONTEXT);
// Timer invocation
if (ejbTimeout.equals(mi.getMethod()))
{
AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT);
}
// Service Endpoint invocation
else if (msgContext != null)
{
if (msgContext instanceof javax.xml.rpc.handler.MessageContext)
ctx.setMessageContext((javax.xml.rpc.handler.MessageContext)msgContext);
AllowedOperationsAssociation.pushInMethodFlag(IN_SERVICE_ENDPOINT_METHOD);
}
// Business Method Invocation