(this.handlers).size(),
+ Assert.isTrue(this.handlers.size() == new HashSet<>(this.handlers).size(),
"duplicate handlers are not allowed in a chain");
for (int i = 0; i < this.handlers.size(); i++) {
MessageHandler handler = this.handlers.get(i);
@@ -120,10 +119,11 @@ public class MessageHandlerChain extends AbstractMessageProducingHandler
"the last one in the chain must implement the MessageProducer interface.");
MessageHandler nextHandler = this.handlers.get(i + 1);
- MessageChannel nextChannel = (message, timeout) -> {
- nextHandler.handleMessage(message);
- return true;
- };
+ MessageChannel nextChannel =
+ (message, timeout) -> {
+ nextHandler.handleMessage(message);
+ return true;
+ };
((MessageProducer) handler).setOutputChannel(nextChannel);
@@ -146,6 +146,14 @@ public class MessageHandlerChain extends AbstractMessageProducingHandler
}
}
+ @Override
+ protected void handleMessageInternal(Message> message) {
+ if (!this.initialized) {
+ onInit();
+ }
+ this.handlers.get(0).handleMessage(message);
+ }
+
@Override
protected boolean shouldCopyRequestHeaders() {
return false;
@@ -171,7 +179,7 @@ public class MessageHandlerChain extends AbstractMessageProducingHandler
this.lifecycleLock.lock();
try {
if (!this.running) {
- this.doStart();
+ doStart();
this.running = true;
if (logger.isInfoEnabled()) {
logger.info("started " + this);
@@ -188,7 +196,7 @@ public class MessageHandlerChain extends AbstractMessageProducingHandler
this.lifecycleLock.lock();
try {
if (this.running) {
- this.doStop();
+ doStop();
this.running = false;
if (logger.isInfoEnabled()) {
logger.info("stopped " + this);
@@ -203,7 +211,7 @@ public class MessageHandlerChain extends AbstractMessageProducingHandler
public final void stop(Runnable callback) {
this.lifecycleLock.lock();
try {
- this.stop();
+ stop();
callback.run();
}
finally {
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/ReplyProducingMessageHandlerWrapper.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/ReplyProducingMessageHandlerWrapper.java
index c72e35eaaf..a36487ee8d 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/handler/ReplyProducingMessageHandlerWrapper.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/ReplyProducingMessageHandlerWrapper.java
@@ -17,6 +17,8 @@
package org.springframework.integration.handler;
import org.springframework.context.Lifecycle;
+import org.springframework.integration.IntegrationPattern;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.util.Assert;
@@ -44,6 +46,13 @@ public class ReplyProducingMessageHandlerWrapper extends AbstractReplyProducingM
this.target = target;
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return (this.target instanceof IntegrationPattern)
+ ? ((IntegrationPattern) this.target).getIntegrationPatternType()
+ : IntegrationPatternType.service_activator;
+ }
+
@Override
protected Object handleRequestMessage(Message> requestMessage) {
this.target.handleMessage(requestMessage);
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java
index 5173c3425b..25a9d88368 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java
@@ -21,6 +21,8 @@ import java.lang.reflect.Method;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.context.Lifecycle;
import org.springframework.core.convert.ConversionService;
+import org.springframework.integration.IntegrationPattern;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
@@ -57,6 +59,13 @@ public class ServiceActivatingHandler extends AbstractReplyProducingMessageHandl
return "service-activator";
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return (this.processor instanceof IntegrationPattern)
+ ? ((IntegrationPattern) this.processor).getIntegrationPatternType()
+ : IntegrationPatternType.service_activator;
+ }
+
@Override
protected void doInit() {
if (this.processor instanceof AbstractMessageProcessor) {
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java
index 7d27c6546f..3612ff62fd 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java
@@ -19,8 +19,10 @@ package org.springframework.integration.router;
import java.util.Collection;
import java.util.UUID;
+import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.support.management.IntegrationManagedResource;
@@ -61,8 +63,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler imple
* fails to return any channels. If no default channel is provided and channel
* resolution fails to return any channels, the router will throw an
* {@link MessageDeliveryException}.
- *
- * If messages shall be ignored (dropped) instead, please provide a
+ *
If messages shall be ignored (dropped) instead, please provide a
* {@link org.springframework.integration.channel.NullChannel}.
* @param defaultOutputChannel The default output channel.
*/
@@ -129,6 +130,11 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler imple
return "router";
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return IntegrationPatternType.router;
+ }
+
/**
* Provides {@link MessagingTemplate} access for subclasses
* @return The messaging template.
@@ -151,8 +157,9 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler imple
super.onInit();
Assert.state(!(this.defaultOutputChannelName != null && this.defaultOutputChannel != null),
"'defaultOutputChannelName' and 'defaultOutputChannel' are mutually exclusive.");
- if (this.getBeanFactory() != null) {
- this.messagingTemplate.setBeanFactory(this.getBeanFactory());
+ BeanFactory beanFactory = getBeanFactory();
+ if (beanFactory != null) {
+ this.messagingTemplate.setBeanFactory(beanFactory);
}
}
@@ -167,7 +174,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler imple
@Override
protected void handleMessageInternal(Message> message) {
boolean sent = false;
- Collection results = this.determineTargetChannels(message);
+ Collection results = determineTargetChannels(message);
if (results != null) {
int sequenceSize = results.size();
int sequenceNumber = 1;
@@ -179,10 +186,10 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler imple
else {
UUID id = message.getHeaders().getId();
messageToSend = getMessageBuilderFactory()
- .fromMessage(message)
- .pushSequenceDetails(id == null ? generateId() : id,
- sequenceNumber++, sequenceSize)
- .build();
+ .fromMessage(message)
+ .pushSequenceDetails(id == null ? generateId() : id,
+ sequenceNumber++, sequenceSize)
+ .build();
}
if (channel != null) {
sent |= doSend(channel, messageToSend);
@@ -195,7 +202,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler imple
this.messagingTemplate.send(this.defaultOutputChannel, message);
}
else {
- throw new MessageDeliveryException(message, "No channel resolved by router '" + this.getComponentName()
+ throw new MessageDeliveryException(message, "No channel resolved by router '" + this
+ "' and no 'defaultOutputChannel' defined.");
}
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java
index 670b05f90c..bccac4c44e 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/router/RecipientListRouter.java
@@ -30,6 +30,7 @@ import java.util.stream.Collectors;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.filter.ExpressionEvaluatingSelector;
import org.springframework.jmx.export.annotation.ManagedAttribute;
@@ -250,6 +251,11 @@ public class RecipientListRouter extends AbstractMessageRouter implements Recipi
return "recipient-list-router";
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return IntegrationPatternType.recipient_list_router;
+ }
+
@Override
protected Collection determineTargetChannels(Message> message) {
return this.recipients.stream()
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java
index 83288d2bf9..8998fffc8f 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/scattergather/ScatterGatherHandler.java
@@ -20,6 +20,7 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.context.Lifecycle;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.channel.FixedSubscriberChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.channel.ReactiveStreamsSubscribableChannel;
@@ -107,6 +108,16 @@ public class ScatterGatherHandler extends AbstractReplyProducingMessageHandler i
this.errorChannelName = errorChannelName;
}
+ @Override
+ public String getComponentType() {
+ return "scatter-gather";
+ }
+
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return IntegrationPatternType.scatter_gather;
+ }
+
@Override
protected void doInit() {
BeanFactory beanFactory = getBeanFactory();
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java b/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java
index eb4f25532d..5e2988cd30 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java
@@ -28,6 +28,7 @@ import java.util.stream.Stream;
import org.reactivestreams.Publisher;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.channel.ReactiveStreamsSubscribableChannel;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.handler.DiscardingMessageHandler;
@@ -107,6 +108,11 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess
return this.discardChannel;
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return IntegrationPatternType.splitter;
+ }
+
@Override
protected void doInit() {
Assert.state(!(this.discardChannelName != null && this.discardChannel != null),
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckInTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckInTransformer.java
index c3bf430495..440d9f8e5f 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckInTransformer.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckInTransformer.java
@@ -18,8 +18,9 @@ package org.springframework.integration.transformer;
import java.util.UUID;
+import org.springframework.integration.IntegrationPattern;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.store.MessageStore;
-import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
@@ -28,9 +29,11 @@ import org.springframework.util.Assert;
* is the id of the stored Message.
*
* @author Mark Fisher
+ * @author Artem Bilan
+ *
* @since 2.0
*/
-public class ClaimCheckInTransformer extends AbstractTransformer {
+public class ClaimCheckInTransformer extends AbstractTransformer implements IntegrationPattern {
private final MessageStore messageStore;
@@ -50,16 +53,18 @@ public class ClaimCheckInTransformer extends AbstractTransformer {
return "claim-check-in";
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return IntegrationPatternType.claim_check_in;
+ }
+
@Override
protected Object doTransform(Message> message) {
Assert.notNull(message, "message must not be null");
UUID id = message.getHeaders().getId();
Assert.notNull(id, "ID header must not be null");
this.messageStore.addMessage(message);
- AbstractIntegrationMessageBuilder> responseBuilder = getMessageBuilderFactory().withPayload(id);
- // headers on the 'current' message take precedence
- responseBuilder.copyHeaders(message.getHeaders());
- return responseBuilder.build();
+ return id;
}
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckOutTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckOutTransformer.java
index 3f7c81a2ff..54f57f56c5 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckOutTransformer.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ClaimCheckOutTransformer.java
@@ -18,6 +18,8 @@ package org.springframework.integration.transformer;
import java.util.UUID;
+import org.springframework.integration.IntegrationPattern;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.store.MessageStore;
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
import org.springframework.messaging.Message;
@@ -31,9 +33,11 @@ import org.springframework.util.Assert;
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Nick Spacek
+ * @author Artem Bilan
+ *
* @since 2.0
*/
-public class ClaimCheckOutTransformer extends AbstractTransformer {
+public class ClaimCheckOutTransformer extends AbstractTransformer implements IntegrationPattern {
private final MessageStore messageStore;
@@ -59,6 +63,11 @@ public class ClaimCheckOutTransformer extends AbstractTransformer {
return "claim-check-out";
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return IntegrationPatternType.claim_check_in;
+ }
+
@Override
protected Object doTransform(Message> message) {
Assert.notNull(message, "message must not be null");
@@ -74,9 +83,9 @@ public class ClaimCheckOutTransformer extends AbstractTransformer {
else {
retrievedMessage = this.messageStore.getMessage(id);
}
- Assert.notNull(retrievedMessage, "unable to locate Message for ID: " + id
- + " within MessageStore [" + this.messageStore + "]");
- AbstractIntegrationMessageBuilder> responseBuilder = this.getMessageBuilderFactory().fromMessage(retrievedMessage);
+ Assert.notNull(retrievedMessage,
+ () -> "unable to locate Message for ID: " + id + " within MessageStore [" + this.messageStore + "]");
+ AbstractIntegrationMessageBuilder> responseBuilder = getMessageBuilderFactory().fromMessage(retrievedMessage);
// headers on the 'current' message take precedence
responseBuilder.copyHeaders(message.getHeaders());
return responseBuilder.build();
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ContentEnricher.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ContentEnricher.java
index ab6e6e8330..d87db1b092 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ContentEnricher.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ContentEnricher.java
@@ -28,6 +28,7 @@ import org.springframework.expression.Expression;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.integration.gateway.MessagingGatewaySupport;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
@@ -254,6 +255,11 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
return "enricher";
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return IntegrationPatternType.content_enricher;
+ }
+
/**
* Initializes the Content Enricher. Will instantiate an internal Gateway if the
* requestChannel is set.
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java
index ea49030944..f90bffde1a 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderEnricher.java
@@ -22,6 +22,8 @@ import java.util.Map.Entry;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanInitializationException;
+import org.springframework.integration.IntegrationPattern;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.handler.MessageProcessor;
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
@@ -41,7 +43,7 @@ import org.springframework.messaging.MessageHeaders;
* @author Artem Bilan
* @author Gary Russell
*/
-public class HeaderEnricher extends IntegrationObjectSupport implements Transformer {
+public class HeaderEnricher extends IntegrationObjectSupport implements Transformer, IntegrationPattern {
private final Map> headersToAdd;
@@ -92,6 +94,47 @@ public class HeaderEnricher extends IntegrationObjectSupport implements Transfor
return "header-enricher";
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return IntegrationPatternType.header_enricher;
+ }
+
+ @Override
+ public void onInit() {
+ boolean shouldOverwrite = this.defaultOverwrite;
+ boolean checkReadOnlyHeaders = getMessageBuilderFactory() instanceof DefaultMessageBuilderFactory;
+
+ for (Entry> entry : this.headersToAdd.entrySet()) {
+ if (checkReadOnlyHeaders &&
+ (MessageHeaders.ID.equals(entry.getKey()) || MessageHeaders.TIMESTAMP.equals(entry.getKey()))) {
+ throw new BeanInitializationException(
+ "HeaderEnricher cannot override 'id' and 'timestamp' read-only headers.\n" +
+ "Wrong 'headersToAdd' [" + this.headersToAdd
+ + "] configuration for " + getComponentName());
+ }
+
+ HeaderValueMessageProcessor> processor = entry.getValue();
+ if (processor instanceof BeanFactoryAware && getBeanFactory() != null) {
+ ((BeanFactoryAware) processor).setBeanFactory(getBeanFactory());
+ }
+ Boolean processorOverwrite = processor.isOverwrite();
+ if (processorOverwrite != null) {
+ shouldOverwrite |= processorOverwrite;
+ }
+ }
+
+ if (this.messageProcessor != null
+ && this.messageProcessor instanceof BeanFactoryAware
+ && getBeanFactory() != null) {
+ ((BeanFactoryAware) this.messageProcessor).setBeanFactory(getBeanFactory());
+ }
+
+ if (!shouldOverwrite && !this.shouldSkipNulls && logger.isWarnEnabled()) {
+ logger.warn(getComponentName() +
+ " is configured to not overwrite existing headers. 'shouldSkipNulls = false' will have no effect");
+ }
+ }
+
@Override
public Message> transform(Message> message) {
MessageHeaders messageHeaders = message.getHeaders();
@@ -152,40 +195,4 @@ public class HeaderEnricher extends IntegrationObjectSupport implements Transfor
}
}
- @Override
- public void onInit() {
- boolean shouldOverwrite = this.defaultOverwrite;
- boolean checkReadOnlyHeaders = getMessageBuilderFactory() instanceof DefaultMessageBuilderFactory;
-
- for (Entry> entry : this.headersToAdd.entrySet()) {
- if (checkReadOnlyHeaders &&
- (MessageHeaders.ID.equals(entry.getKey()) || MessageHeaders.TIMESTAMP.equals(entry.getKey()))) {
- throw new BeanInitializationException(
- "HeaderEnricher cannot override 'id' and 'timestamp' read-only headers.\n" +
- "Wrong 'headersToAdd' [" + this.headersToAdd
- + "] configuration for " + getComponentName());
- }
-
- HeaderValueMessageProcessor> processor = entry.getValue();
- if (processor instanceof BeanFactoryAware && getBeanFactory() != null) {
- ((BeanFactoryAware) processor).setBeanFactory(getBeanFactory());
- }
- Boolean processorOverwrite = processor.isOverwrite();
- if (processorOverwrite != null) {
- shouldOverwrite |= processorOverwrite;
- }
- }
-
- if (this.messageProcessor != null
- && this.messageProcessor instanceof BeanFactoryAware
- && getBeanFactory() != null) {
- ((BeanFactoryAware) this.messageProcessor).setBeanFactory(getBeanFactory());
- }
-
- if (!shouldOverwrite && !this.shouldSkipNulls && logger.isWarnEnabled()) {
- logger.warn(getComponentName() +
- " is configured to not overwrite existing headers. 'shouldSkipNulls = false' will have no effect");
- }
- }
-
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderFilter.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderFilter.java
index 1b917a47c8..4f211e6e01 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderFilter.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/HeaderFilter.java
@@ -19,6 +19,8 @@ package org.springframework.integration.transformer;
import java.util.Arrays;
import org.springframework.beans.factory.BeanInitializationException;
+import org.springframework.integration.IntegrationPattern;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
import org.springframework.integration.support.DefaultMessageBuilderFactory;
@@ -36,7 +38,7 @@ import org.springframework.util.Assert;
*
* @since 2.0
*/
-public class HeaderFilter extends IntegrationObjectSupport implements Transformer {
+public class HeaderFilter extends IntegrationObjectSupport implements Transformer, IntegrationPattern {
private final String[] headersToRemove;
@@ -57,6 +59,11 @@ public class HeaderFilter extends IntegrationObjectSupport implements Transforme
return "header-filter";
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return IntegrationPatternType.header_filter;
+ }
+
@Override
protected void onInit() {
super.onInit();
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java
index 6b0803a0de..118204d0b1 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java
@@ -20,6 +20,8 @@ import java.util.Collection;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.context.Lifecycle;
+import org.springframework.integration.IntegrationPattern;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.messaging.Message;
@@ -60,6 +62,13 @@ public class MessageTransformingHandler extends AbstractReplyProducingMessageHan
((NamedComponent) this.transformer).getComponentType() : "transformer";
}
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return (this.transformer instanceof IntegrationPattern)
+ ? ((IntegrationPattern) this.transformer).getIntegrationPatternType()
+ : IntegrationPatternType.transformer;
+ }
+
@Override
public void addNotPropagatedHeaders(String... headers) {
super.addNotPropagatedHeaders(headers);
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java
index 039605ce95..2f4bfa180f 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/support/management/graph/IntegrationGraphServerTests.java
@@ -215,6 +215,24 @@ public class IntegrationGraphServerTests {
JsonPathUtils.evaluate(baos.toByteArray(),
"$..links[?(@.from == " + routerNodeId + "&& @.to == " + fizChannelNodeId + ")]");
assertThat(jsonArray).hasSize(1);
+
+ jsonArray = JsonPathUtils.evaluate(baos.toByteArray(),
+ "$..nodes[?(@.name == 'services.foo.serviceActivator.handler')]");
+
+ assertThat(jsonArray).hasSize(1);
+
+ Map serviceActivator = (Map) jsonArray.get(0);
+ assertThat(serviceActivator).containsEntry("integrationPatternType", "service_activator");
+
+ jsonArray = JsonPathUtils.evaluate(baos.toByteArray(),
+ "$..nodes[?(@.name == 'polling')]");
+
+ assertThat(jsonArray).hasSize(1);
+
+ serviceActivator = (Map) jsonArray.get(0);
+ assertThat(serviceActivator)
+ .containsEntry("integrationPatternType", "service_activator")
+ .containsEntry("integrationPatternCategory", "messaging_endpoint");
}
@Test
diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java b/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java
index a996dfec8a..f60c340f60 100644
--- a/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java
+++ b/spring-integration-file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java
@@ -49,6 +49,7 @@ import org.springframework.context.Lifecycle;
import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.support.StandardEvaluationContext;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.integration.file.support.FileExistsMode;
import org.springframework.integration.file.support.FileUtils;
@@ -302,7 +303,7 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
*/
public void setCharset(String charset) {
Assert.notNull(charset, "charset must not be null");
- Assert.isTrue(Charset.isSupported(charset), "Charset '" + charset + "' is not supported.");
+ Assert.isTrue(Charset.isSupported(charset), () -> "Charset '" + charset + "' is not supported.");
this.charset = Charset.forName(charset);
}
@@ -412,6 +413,16 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
this.newFileCallback = newFileCallback;
}
+ @Override
+ public String getComponentType() {
+ return this.expectReply ? "file:outbound-gateway" : "file:outbound-channel-adapter";
+ }
+
+ @Override
+ public IntegrationPatternType getIntegrationPatternType() {
+ return this.expectReply ? super.getIntegrationPatternType() : IntegrationPatternType.outbound_channel_adapter;
+ }
+
@Override
protected void doInit() {
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
@@ -548,7 +559,7 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
private File writeMessageToFile(Message> requestMessage, File originalFileFromHeader, File tempFile,
File resultFile, Object timestamp) throws IOException {
- File fileToReturn = null;
+ File fileToReturn;
Object payload = requestMessage.getPayload();
if (payload instanceof File) {
fileToReturn = handleFileMessage((File) payload, tempFile, resultFile, requestMessage);
diff --git a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyCommandMessageProcessor.java b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyCommandMessageProcessor.java
index ccaf46308a..36afb682f0 100644
--- a/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyCommandMessageProcessor.java
+++ b/spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyCommandMessageProcessor.java
@@ -21,8 +21,11 @@ import java.io.UncheckedIOException;
import java.util.Map;
import java.util.UUID;
+import org.springframework.integration.IntegrationPattern;
+import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.scripting.AbstractScriptExecutingMessageProcessor;
import org.springframework.integration.scripting.ScriptVariableGenerator;
+import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.scripting.ScriptSource;
import org.springframework.scripting.groovy.GroovyObjectCustomizer;
@@ -45,10 +48,12 @@ import groovy.lang.GString;
*
* @since 2.0
*/
-public class GroovyCommandMessageProcessor extends AbstractScriptExecutingMessageProcessor