GH-8626: Provide cleaner transform() DSL (#8653)
* GH-8626: Provide cleaner `transform()` DSL Fixes https://github.com/spring-projects/spring-integration/issues/8626 * Add missed `transform(String beanName, @Nullable String methodName)` API * Introduce a `TransformerSpec` to expose a strict API to configure transformer variants. * Introduce `transformWith(Consumer<TransformerSpec>)` as a single point of all possible transformer and its endpoint options * Deprecate those `IntegrationFlowDefinition.transform()` variants which are harder to configure as several lambda arguments This change will make Kotlin & Groovy DSL more readable and straightforward * * Use new `transformWith()` in tests where a deprecated API still used * Add JavaDocs to `TransformerSpec` * Fix generic types for `BaseIntegrationFlowDefinition.transformWith()` - they make sense exactly on the `TransformerSpec.transformer()` only * Apply `transformWith()` for Groovy DSL * Introduce a new `ClassUtils.isLambda(Object candidate)` and add a check for Groovy `Closure` * Fix `GroovyIntegrationFlowDefinition.createConfigurerIfAny()` to propagate a `Consumer` argument down to the `Closure` * * Rename `TransformerSpec -> TransformerEndpointSpec` for better context meaning of the class * Introduce `KotlinTransformerEndpointSpec` as an extension of the `TransformerEndpointSpec` to have an `inline fun <reified P> transformer(crossinline function: (P) -> Any)` for Kotlin style * Add `KotlinIntegrationFlowDefinition.transformWith(KotlinTransformerEndpointSpec)` * Deprecate Kotlin methods which are covered by the mentioned `transformWith()` * Fix tests to use new API * Mentioned the change in the doc
This commit is contained in:
@@ -448,8 +448,9 @@ public class FileTests {
|
||||
.from(Files.inboundAdapter(directory).recursive(true),
|
||||
e -> e.poller(p -> p.fixedDelay(1000))
|
||||
.id(directory.getName() + ".adapter"))
|
||||
.transform(Files.toStringTransformer(),
|
||||
e -> e.id(directory.getName() + ".transformer"))
|
||||
.transformWith(t -> t
|
||||
.transformer(Files.toStringTransformer())
|
||||
.id(directory.getName() + ".transformer"))
|
||||
.channel(this.dynamicAdaptersResult)
|
||||
.get();
|
||||
this.beanFactory.initializeBean(integrationFlow, directory.getName());
|
||||
|
||||
Reference in New Issue
Block a user