args = new Object[]{};
}
// Initialize interceptor stack
List<InterceptorData> interceptors = beanContext.getMethodInterceptors(runMethod);
InterceptorStack interceptorStack = new InterceptorStack(instance.bean, runMethod, Operation.REMOVE, interceptors, instance.interceptors);
// Invoke
if (args == null){
returnValue = interceptorStack.invoke();
} else {
returnValue = interceptorStack.invoke(args);
}
}
} catch (InvalidateReferenceException e) {
throw e;
} catch (Throwable e) {
if (interfaceType.isBusiness()) {
retain = beanContext.retainIfExeption(runMethod);
handleException(callContext, txPolicy, e);
} else {
try {
handleException(callContext, txPolicy, e);
} catch (ApplicationException ae){
// Don't throw application exceptions for non-business interface removes
}
}
} finally {
if (!retain) {
try {
callContext.setCurrentOperation(Operation.PRE_DESTROY);
List<InterceptorData> callbackInterceptors = beanContext.getCallbackInterceptors();
if (instance != null) {
InterceptorStack interceptorStack = new InterceptorStack(instance.bean, null, Operation.PRE_DESTROY, callbackInterceptors, instance.interceptors);
interceptorStack.invoke();
}
} catch (Throwable t) {
final String logMessage = "An unexpected exception occured while invoking the preDestroy method on the Stateful SessionBean instance: "
+ (null != instance ? instance.bean.getClass().getName() : beanContext.getBeanClass().getName());
logger.error(logMessage, t);