{
MethodDescriptor md = new MethodDescriptor(method, methodIntf);
boolean flushEnabled = findFlushEnabledAttr(md);
int txAttr = containerTransactionManager.findTxAttr(md);
InvocationInfo info = createInvocationInfo
(method, txAttr, flushEnabled, methodIntf, originalIntf);
boolean isHomeIntf = (methodIntf.equals(MethodDescriptor.EJB_HOME)
|| methodIntf.equals(MethodDescriptor.EJB_LOCALHOME));
if (! isHomeIntf) {
Method beanMethod = null;
if (!isEjbTimeout) {
try {
beanMethod = getEJBClass().getMethod(
method.getName(), method.getParameterTypes());
} catch (NoSuchMethodException nsmEx) {
//TODO
}
} else {
// For a timeout it is the method
beanMethod = method;
}
if( beanMethod != null ) {
// Can't set AroundInvoke/AroundTimeout chains here, but set up some
// state on info object so it can be done right after InterceptorManager
// is initialized.
info.aroundMethod = beanMethod;
info.isEjbTimeout = isEjbTimeout;
}
// Asynchronous method initialization
if ( isEligibleForAsync(originalIntf, methodIntf) ) {
Method targetMethod = optionalLocalBusView ? beanMethod : method;
boolean isAsync = ((EjbSessionDescriptor) ejbDescriptor).
isAsynchronousMethod(targetMethod);
if( isAsync ) {
// Check return type
if( optionalLocalBusView ) {
boolean beanMethodReturnTypeVoid = beanMethod.getReturnType().equals(Void.TYPE);
boolean beanMethodReturnTypeFuture = beanMethod.getReturnType().equals(Future.class);
if ( !beanMethodReturnTypeVoid && !beanMethodReturnTypeFuture ){
throw new RuntimeException("Invalid no-interface view asynchronous method '"
+ beanMethod + "' for bean " + ejbDescriptor.getName() +
". Async method exposed through no-interface view must " +
" have return type void or java.lang.concurrent.Future<V>");
}
} else {
// Use actual interface method instead of method from generated interface
Method intfMethod = null;
try {
intfMethod = originalIntf.getMethod(
method.getName(), method.getParameterTypes());
} catch (NoSuchMethodException nsmEx) {
throw new RuntimeException("No matching async intf method for method '" +
beanMethod + "' on bean " + ejbDescriptor.getName());
}
if( beanMethod == null ) {
throw new RuntimeException("No matching bean class method for async method '" +
intfMethod + "' on bean " + ejbDescriptor.getName());
}
boolean beanMethodReturnTypeVoid = beanMethod.getReturnType().equals(Void.TYPE);
boolean beanMethodReturnTypeFuture = beanMethod.getReturnType().equals(Future.class);
boolean intfMethodReturnTypeVoid = intfMethod.getReturnType().equals(Void.TYPE);
boolean intfMethodReturnTypeFuture = intfMethod.getReturnType().equals(Future.class);
boolean bothVoid = intfMethodReturnTypeVoid && beanMethodReturnTypeVoid;
boolean bothFuture = intfMethodReturnTypeFuture && beanMethodReturnTypeFuture;
boolean valid = false;
if( bothVoid ) {
valid = true;
} else if( bothFuture ) {
valid = true;
}
if( !valid ) {
throw new RuntimeException("Invalid asynchronous bean class / interface " +
"method signatures for bean " + ejbDescriptor.getName() +
". beanMethod = '" + beanMethod + "' , interface method = '"
+ intfMethod + "'");
}
}
info.setIsAsynchronous(true);
}
}
}