GH-676 Improvements to header enrichment

This commit is contained in:
Oleg Zhurakousky
2021-05-19 16:52:50 +02:00
parent c86ce12484
commit 238ac301df
3 changed files with 86 additions and 73 deletions

View File

@@ -283,9 +283,8 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
FunctionInvocationWrapper andThenFunction =
invocationWrapperInstance(functionName, function.getTarget(), function.inputType, function.outputType);
composedFunction = (FunctionInvocationWrapper) composedFunction.andThen((Function<Object, Object>) andThenFunction);
composedFunction = this.enrichInputIfNecessary(composedFunction);
}
composedFunction = this.enrichInputIfNecessary(composedFunction);
this.wrappedFunctionDefinitions.put(composedFunction.functionDefinition, composedFunction);
}
}
@@ -304,17 +303,18 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
if (!CollectionUtils.isEmpty(configurationProperties)) {
FunctionConfigurationProperties configuration = configurationProperties
.get(functionDefinition.replace("|", "").replace(",", ""));
if (!CollectionUtils.isEmpty(configuration.getInputHeaderMappingExpression())) {
BeanFactoryResolver beanResolver = this.functionProperties.getApplicationContext() != null
? new BeanFactoryResolver(this.functionProperties.getApplicationContext())
: null;
InputEnricher enricher = new InputEnricher(configuration.getInputHeaderMappingExpression(), beanResolver);
FunctionInvocationWrapper w = new FunctionInvocationWrapper("headerEnricher", enricher, Message.class, Message.class);
composedFunction = (FunctionInvocationWrapper) w.andThen((Function<Object, Object>) composedFunction);
composedFunction.functionDefinition = functionDefinition;
if (configuration != null) {
if (!CollectionUtils.isEmpty(configuration.getInputHeaderMappingExpression())) {
BeanFactoryResolver beanResolver = this.functionProperties.getApplicationContext() != null
? new BeanFactoryResolver(this.functionProperties.getApplicationContext())
: null;
InputEnricher enricher = new InputEnricher(configuration.getInputHeaderMappingExpression(), beanResolver);
FunctionInvocationWrapper w = new FunctionInvocationWrapper("headerEnricher", enricher, Message.class, Message.class);
composedFunction = (FunctionInvocationWrapper) w.andThen((Function<Object, Object>) composedFunction);
composedFunction.functionDefinition = functionDefinition;
}
}
}
return composedFunction;
}