if (args == null) {
args = NO_ARGS;
}
// get the context data
ThreadContext callContext = ThreadContext.getThreadContext();
CoreDeploymentInfo deployInfo = callContext.getDeploymentInfo();
MdbCallContext mdbCallContext = callContext.get(MdbCallContext.class);
if (mdbCallContext == null) {
throw new IllegalStateException("beforeDelivery was not called");
}
// verify the delivery method passed to beforeDeliver is the same method that was invoked
if (!mdbCallContext.deliveryMethod.getName().equals(method.getName()) ||
!Arrays.deepEquals(mdbCallContext.deliveryMethod.getParameterTypes(), method.getParameterTypes())) {
throw new IllegalStateException("Delivery method specified in beforeDelivery is not the delivery method called");
}
// remember the return value or exception so it can be logged
Object returnValue = null;
OpenEJBException openEjbException = null;
Operation oldOperation = callContext.getCurrentOperation();
callContext.setCurrentOperation(Operation.BUSINESS);
BaseContext.State[] originalStates = callContext.setCurrentAllowedStates(MdbContext.getStates());
try {
if (logger.isInfoEnabled()) {
logger.info("invoking method " + method.getName() + " on " + deployInfo.getDeploymentID());
}
// determine the target method on the bean instance class
Method targetMethod = deployInfo.getMatchingBeanMethod(method);
callContext.set(Method.class, targetMethod);
// invoke the target method
returnValue = _invoke(instance, targetMethod, args, deployInfo, mdbCallContext);
return returnValue;
} catch (ApplicationException e) {
openEjbException = e;
throw e;
} catch (SystemException e) {
openEjbException = e;
throw e;
} finally {
callContext.setCurrentOperation(oldOperation);
callContext.setCurrentAllowedStates(originalStates);
// Log the invocation results
if (logger.isDebugEnabled()) {
if (openEjbException == null) {
logger.debug("finished invoking method " + method.getName() + ". Return value:" + returnValue);
} else {