FunctionExpression

我们引入了 FunctionExpression 类(SpEL 的 Expression 接口的一个实现),它允许我们使用 lambda 表达式和泛型。当核心 Spring Integration 中存在隐式的 Strategy 变体时,会为 DSL 组件提供 Function<T, R> 选项以及 expression 选项。以下示例展示了如何使用函数表达式。

.enrich(e -> e.requestChannel("enrichChannel")
            .requestPayload(Message::getPayload)
            .propertyFunction("date", m -> new Date()))

FunctionExpression 还支持运行时类型转换,与 SpelExpression 中的做法相同。

© . This site is unofficial and not affiliated with VMware.