Fixed function registration when function is not a bean

This commit is contained in:
Oleg Zhurakousky
2019-06-27 14:39:08 +03:00
parent 72b847595d
commit febf0e06ba
4 changed files with 18 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-function-context</artifactId>
@@ -58,6 +58,14 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -56,7 +56,7 @@ class FunctionTypeConversionHelper {
this.functionArgumentTypes = ((ParameterizedType)this.functionRegistration.getType().getType()).getActualTypeArguments();
}
else {
this.functionArgumentTypes = new Type[] {this.functionRegistration.getType().getType()};
this.functionArgumentTypes = new Type[] {this.functionRegistration.getType().getInputType()};
}
}

View File

@@ -118,6 +118,9 @@ public class LazyFunctionRegistry implements FunctionRegistry, FunctionInspector
@Override
public <T> void register(FunctionRegistration<T> registration) {
this.registrationsByFunction.put(registration.getTarget(), (FunctionRegistration<Object>) registration);
for (String name : registration.getNames()) {
this.registrationsByName.put(name, (FunctionRegistration<Object>) registration);
}
}
@Override

View File

@@ -92,10 +92,10 @@ public class ContextFunctionCatalogAutoConfiguration {
static final String PREFERRED_MAPPER_PROPERTY = "spring.http.converters.preferred-json-mapper";
// @Bean
// public FunctionRegistry functionCatalog() {
// return new BeanFactoryFunctionCatalog();
// }
//@Bean
public FunctionRegistry functionCatalog() {
return new BeanFactoryFunctionCatalog();
}
@Bean
public FunctionRegistry functionCatalog(@Nullable ConversionService conversionService, @Nullable CompositeMessageConverter messageConverter,