private static BeanInstantiatorForge resolveFactoryMethod(BeanEventType beanEventType, ClasspathImportService classpathImportService)
throws EventBeanManufactureException {
String factoryMethodName = beanEventType.getFactoryMethodName();
int lastDotIndex = factoryMethodName.lastIndexOf('.');
if (lastDotIndex == -1) {
try {
Method method = classpathImportService.resolveMethod(beanEventType.getUnderlyingType(), factoryMethodName, new Class[0], new boolean[0], new boolean[0]);
return new BeanInstantiatorForgeByReflection(method);
} catch (ClasspathImportException e) {
String message = "Failed to resolve configured factory method '" + factoryMethodName +
"' expected to exist for class '" + beanEventType.getUnderlyingType() + "'";
log.info(message, e);
throw new EventBeanManufactureException(message, e);
}
}
String className = factoryMethodName.substring(0, lastDotIndex);
String methodName = factoryMethodName.substring(lastDotIndex + 1);
try {
Method method = classpathImportService.resolveMethodOverloadChecked(className, methodName, new Class[0], new boolean[0], new boolean[0]);
return new BeanInstantiatorForgeByReflection(method);
} catch (ClasspathImportException e) {
String message = "Failed to resolve configured factory method '" + methodName + "' expected to exist for class '" + className + "'";
log.info(message, e);
throw new EventBeanManufactureException(message, e);
}
}
}