ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
try
{
// create a (AOP) MethodInfo first so that a AOP based container invocation can be created out of it
long hash = MethodHashing.calculateHash(tMethod);
MethodInfo methodInfo = getAdvisor().getMethodInfo(hash);
if (methodInfo == null)
{
throw new RuntimeException("MethodInfo not found for timeout method " + tMethod.toString()
+ ", probable error in virtual method registration w/ Advisor for the Container of bean " + this.getEjbName());
}
// get hold of the unadvised method, so that we can mark it accessible
// for the duration of this call (Remember, timeout methods can be with private, protected, package access modifier)
Method unadvisedMethod = methodInfo.getUnadvisedMethod();
// mark as accessible before invoking
unadvisedMethod.setAccessible(true);
// the timeout method (even if private, protected etc...) should pass through the AOP interceptor
// chain. Hence we have a specific AOP interceptor stack for timeout method. Get hold of those interceptors
Interceptor[] timeoutMethodAOPInterceptors = this.getInterceptors(methodInfo.getJoinpoint(),SINGLETON_BEAN_TIMEOUT_METHOD_AOP_INTERCEPTOR_STACK_NAME);
// create a container invocation
ContainerInvocation containerInvocation = new AOPBasedContainerInvocation(methodInfo, args, null, timeoutMethodAOPInterceptors);
// pass the control to the simple singleton container
this.delegate.invoke(containerInvocation);