diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/GenericHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/GenericHandler.java index f0fb62758c..9ef5b36714 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/GenericHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/GenericHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2018 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. @@ -16,7 +16,7 @@ package org.springframework.integration.handler; -import java.util.Map; +import org.springframework.messaging.MessageHeaders; /** * A functional interface to specify {@link org.springframework.messaging.MessageHandler} @@ -36,6 +36,6 @@ import java.util.Map; @FunctionalInterface public interface GenericHandler

{ - Object handle(P payload, Map headers); + Object handle(P payload, MessageHeaders headers); } diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/dsl/IntegrationFlowEventsTests.java b/spring-integration-event/src/test/java/org/springframework/integration/event/dsl/IntegrationFlowEventsTests.java index 2330c0869c..68e771c106 100644 --- a/spring-integration-event/src/test/java/org/springframework/integration/event/dsl/IntegrationFlowEventsTests.java +++ b/spring-integration-event/src/test/java/org/springframework/integration/event/dsl/IntegrationFlowEventsTests.java @@ -22,7 +22,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; -import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import org.junit.BeforeClass; @@ -49,6 +48,7 @@ import org.springframework.integration.store.MessageGroupStore; import org.springframework.integration.store.SimpleMessageStore; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.PollableChannel; import org.springframework.messaging.support.GenericMessage; import org.springframework.test.annotation.DirtiesContext; @@ -148,7 +148,7 @@ public class IntegrationFlowEventsTests { } @Override - public Object handle(Integer p, Map h) { + public Object handle(Integer p, MessageHeaders h) { return p * 2; } diff --git a/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java b/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java index ba4bd552d1..52c95bc542 100644 --- a/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java +++ b/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java @@ -370,7 +370,7 @@ public class WebFluxDslTests { .requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE)) .mappedResponseHeaders("*")) .enrichHeaders(Collections.singletonMap("aHeader", new String[] { "foo", "bar", "baz" })) - .handle((p, h) -> Flux.fromArray((String[]) h.get("aHeader"))) + .handle((p, h) -> Flux.fromArray(h.get("aHeader", String[].class))) .get(); } diff --git a/src/reference/asciidoc/dsl.adoc b/src/reference/asciidoc/dsl.adoc index ca511c82ed..48300c97fe 100644 --- a/src/reference/asciidoc/dsl.adoc +++ b/src/reference/asciidoc/dsl.adoc @@ -476,7 +476,7 @@ Similar lambda configurations are provided for the `resequence()` EIP method. The `.handle()` EIP method's goal is to invoke any `MessageHandler` implementation or any method on some POJO. Another option is to define an "`activity`" by using lambda expressions. Consequently, we introduced a generic `GenericHandler

` functional interface. -Its `handle` method requires two arguments: `P payload` and `Map headers`. +Its `handle` method requires two arguments: `P payload` and `MessageHeaders headers` (starting with version 5.1). Having that, we can define a flow as follows: ==== diff --git a/src/reference/asciidoc/whats-new.adoc b/src/reference/asciidoc/whats-new.adoc index 0397d06792..cefb5db610 100644 --- a/src/reference/asciidoc/whats-new.adoc +++ b/src/reference/asciidoc/whats-new.adoc @@ -41,6 +41,8 @@ This avoid confusion with `log()` which is treated as a one-way end flow compone A generated bean name for any `NamedComponent` within an integration flow is now based on the component type for better readability from visual tools, logs analyzers and metrics collectors. +The `GenericHandler.handle()` now excepts a `MessageHeaders` type for the second argument. + [[x5.1-dispatcher-exceptions]] ==== Dispatcher Exceptions