Fix FunctionTypeUtils for FactoryBean
The function bean can be declared as a `FactoryBean`, for example with Spring Integration's `GatewayProxyFactoryBean`. See `LogConsumerConfiguration` in Spring Functions Catalog project. * Fix `FunctionTypeUtils` to react to the `ParameterizedType` and check its assignments against `Factory` bean. Then resolves its generic to the proper target function type. * Add `BeanFactoryAwareFunctionRegistryTests.functionFromFactoryBeanIsProperlyResolved()` to verify that `FactoryBean<Function<?, ?>>` is resolved properly
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
* Copyright 2019-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -78,6 +78,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Andrey Shlykov
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
@@ -444,6 +445,12 @@ public final class FunctionTypeUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type instanceof ParameterizedType) {
|
||||
ResolvableType resolvableType = ResolvableType.forType(type);
|
||||
if (FactoryBean.class.isAssignableFrom(resolvableType.toClass())) {
|
||||
return resolvableType.getGeneric(0).getType();
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user