diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java index f3d739dd821..691c880fe9d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java @@ -259,6 +259,11 @@ public void run() { } } + @Override + public String getComponentType() { + return "header-channel-registry"; + } + protected record MessageChannelWrapper(MessageChannel channel, long expireAt) { } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/codec/CodecMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/codec/CodecMessageConverter.java index fc74d43e1cb..7de15aaadae 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/codec/CodecMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/codec/CodecMessageConverter.java @@ -77,4 +77,9 @@ public Message toMessage(Object payload, @Nullable MessageHeaders headers) { } } + @Override + public String getComponentType() { + return "converter"; + } + } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java index e7d02d8ad4c..fbb9a0cc4f3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java @@ -138,15 +138,6 @@ public void setComponentName(String componentName) { this.componentName = componentName; } - /** - * Subclasses may implement this method to provide component type information. - */ - @Override - @Nullable - public String getComponentType() { - return null; - } - @Override public void setComponentSource(Object source) { this.beanSource = source; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java index 32ee6587ae4..d69f106317a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java @@ -278,6 +278,11 @@ else if (conversionService.canConvert(key.getClass(), String.class)) { } } + @Override + public String getComponentType() { + return "router-mapping-provider"; + } + } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java index 166f336f7a6..2b3edd6b6bd 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java @@ -183,6 +183,11 @@ public void setTransactionSynchronizationFactory( this.transactionSynchronizationFactory = transactionSynchronizationFactory; } + @Override + public String getComponentType() { + return "polling-endpoint"; + } + /** * Return the default error channel if the error handler is explicitly provided and * it is a {@link MessagePublishingErrorHandler}. diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java index a1604aa472d..32a69fda3cb 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/EventDrivenConsumer.java @@ -123,4 +123,9 @@ private void logComponentSubscriptionEvent(boolean add) { } } + @Override + public String getComponentType() { + return "event-driven"; + } + } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java index 0e3615aed01..3292b8a7b28 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java @@ -111,6 +111,11 @@ public void setOutputChannelName(String outputChannelName) { return this.outputChannel; } + @Override + public String getComponentType() { + return "message-producer"; + } + public void setErrorChannel(MessageChannel errorChannel) { this.errorChannel = errorChannel; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveStreamsConsumer.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveStreamsConsumer.java index ea039ead9dc..81fa64f23c3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveStreamsConsumer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ReactiveStreamsConsumer.java @@ -208,6 +208,11 @@ protected void doStop() { } } + @Override + public String getComponentType() { + return "reactive-streams"; + } + private static final class MessageHandlerSubscriber implements CoreSubscriber>, Disposable, Lifecycle { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java index ac8c8c83bd9..1aeefe0459c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java @@ -1055,6 +1055,11 @@ public void destroy() { this.gatewayMap.values().forEach(MethodInvocationGateway::destroy); } + @Override + public String getComponentType() { + return "gateway-proxy-factory"; + } + private static final class MethodInvocationGateway extends MessagingGatewaySupport { private Expression receiveTimeoutExpression; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/AbstractRequestHandlerAdvice.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/AbstractRequestHandlerAdvice.java index 84ff00899f3..451380ec704 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/AbstractRequestHandlerAdvice.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/advice/AbstractRequestHandlerAdvice.java @@ -73,6 +73,11 @@ public final Object invoke(final MethodInvocation invocation) throws Throwable { } } + @Override + public String getComponentType() { + return "advice"; + } + /** * Subclasses implement this method to apply behavior to the {@link MessageHandler}. *

diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java b/spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java index 5c2aa145cae..c971518e329 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jspecify.annotations.Nullable; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; @@ -52,9 +53,10 @@ public class BeanFactoryChannelResolver implements DestinationResolver deserializer; - @Nullable - private final ClassLoader defaultDeserializerClassLoader; + private final @Nullable ClassLoader defaultDeserializerClassLoader; private final boolean usingDefaultDeserializer; @@ -136,15 +135,14 @@ public Object convert(byte[] source) { if (this.usingDefaultDeserializer) { return deserialize(byteStream); } - else { - Object result = this.deserializer.deserialize(byteStream); - /* Even if there is no knowledge what is the target deserialization algorithm - and malicious code may be executed already, it is still better to fail - with untrusted data rather than just let it pass downstream. - */ - checkAllowList(result.getClass()); - return result; - } + + Object result = this.deserializer.deserialize(byteStream); + /* Even if there is no knowledge what is the target deserialization algorithm + and malicious code may be executed already, it is still better to fail + with untrusted data rather than just let it pass downstream. + */ + checkAllowList(result.getClass()); + return result; } catch (Exception ex) { throw new SerializationFailedException("Failed to deserialize payload. " + diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java index 79962ba06f0..f58cc9db6aa 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java @@ -72,13 +72,11 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException { * @return the converted payload or null if conversion is not possible. */ @Override - public Object fromMessage(Message message, Class targetClass) { + public @Nullable Object fromMessage(Message message, Class targetClass) { if (this.conversionService.canConvert(message.getPayload().getClass(), targetClass)) { return this.conversionService.convert(message.getPayload(), targetClass); } - else { - return null; - } + return null; } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/MapMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/MapMessageConverter.java index 27324f5c214..838fce11732 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/MapMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/MapMessageConverter.java @@ -49,7 +49,7 @@ public class MapMessageConverter implements MessageConverter, BeanFactoryAware { private boolean filterHeadersInToMessage; - private BeanFactory beanFactory; + private @Nullable BeanFactory beanFactory; private MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory(); @@ -97,7 +97,6 @@ public void setFilterHeadersInToMessage(boolean filterHeadersInToMessage) { this.filterHeadersInToMessage = filterHeadersInToMessage; } - @Nullable @Override public Message toMessage(Object object, @Nullable MessageHeaders messageHeaders) { Assert.isInstanceOf(Map.class, object, "This converter expects a Map"); @@ -119,7 +118,6 @@ public Message toMessage(Object object, @Nullable MessageHeaders messageHeade .build(); } - @Nullable @Override public Object fromMessage(Message message, Class clazz) { Map map = new HashMap<>(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/ObjectStringMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/ObjectStringMessageConverter.java index fa7c1fa1d99..b2b750d1be2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/ObjectStringMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/ObjectStringMessageConverter.java @@ -56,9 +56,7 @@ protected Object convertFromInternal(Message message, Class targetClass, @ if (payload instanceof String || payload instanceof byte[]) { return super.convertFromInternal(message, targetClass, conversionHint); } - else { - return payload.toString(); - } + return payload.toString(); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/PassThruMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/PassThruMessageConverter.java index 11f024ae198..96d41713029 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/PassThruMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/PassThruMessageConverter.java @@ -43,13 +43,12 @@ public Object fromMessage(Message message, Class targetClass) { } @Override - public Message toMessage(Object payload, @Nullable MessageHeaders headers) { + public @Nullable Message toMessage(Object payload, @Nullable MessageHeaders headers) { if (payload instanceof byte[]) { return MessageBuilder.withPayload(payload).copyHeaders(headers).build(); } - else { - return null; - } + + return null; } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/SimpleMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/SimpleMessageConverter.java index f2c253d2286..0c035973e38 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/SimpleMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/SimpleMessageConverter.java @@ -51,7 +51,7 @@ public class SimpleMessageConverter implements MessageConverter, BeanFactoryAwar private boolean messageBuilderFactorySet; - private BeanFactory beanFactory; + private @Nullable BeanFactory beanFactory; public SimpleMessageConverter() { } @@ -104,9 +104,8 @@ protected MessageBuilderFactory getMessageBuilderFactory() { return this.messageBuilderFactory; } - @Nullable @Override - public Message toMessage(Object object, @Nullable MessageHeaders headers) { + public @Nullable Message toMessage(Object object, @Nullable MessageHeaders headers) { try { return this.inboundMessageMapper.toMessage(object, headers); } @@ -115,9 +114,8 @@ public Message toMessage(Object object, @Nullable MessageHeaders headers) { } } - @Nullable @Override - public Object fromMessage(Message message, Class targetClass) { + public @Nullable Object fromMessage(Message message, Class targetClass) { try { return this.outboundMessageMapper.fromMessage(message); } @@ -132,7 +130,7 @@ private class DefaultInboundMessageMapper implements InboundMessageMapper toMessage(@Nullable Object object, @Nullable Map headers) { + public @Nullable Message toMessage(@Nullable Object object, @Nullable Map headers) { if (object == null) { return null; } @@ -153,8 +151,8 @@ private static class DefaultOutboundMessageMapper implements OutboundMessageMapp } @Override - public Object fromMessage(@Nullable Message message) { - return (message != null) ? message.getPayload() : null; + public Object fromMessage(Message message) { + return message.getPayload(); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/package-info.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/package-info.java index 9cae5c1d825..843b12cbdd6 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/package-info.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/package-info.java @@ -1,6 +1,5 @@ /** * Provides classes supporting message conversion. */ -@org.springframework.lang.NonNullApi -@org.springframework.lang.NonNullFields +@org.jspecify.annotations.NullMarked package org.springframework.integration.support.converter; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transaction/ExpressionEvaluatingTransactionSynchronizationProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/transaction/ExpressionEvaluatingTransactionSynchronizationProcessor.java index 33108eee637..0ceffab777a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transaction/ExpressionEvaluatingTransactionSynchronizationProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transaction/ExpressionEvaluatingTransactionSynchronizationProcessor.java @@ -131,6 +131,11 @@ public void processAfterRollback(IntegrationResourceHolder holder) { doProcess(holder, this.afterRollbackExpression, this.afterRollbackChannel, "afterRollback"); } + @Override + public String getComponentType() { + return "processor"; + } + private void doProcess(IntegrationResourceHolder holder, Expression expression, @Nullable MessageChannel messageChannel, String expressionType) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractTransformer.java index a1fb4270b66..97fd531ed28 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractTransformer.java @@ -45,6 +45,11 @@ public final Message transform(Message message) { } } + @Override + public String getComponentType() { + return "transformer"; + } + /** * Subclasses must implement this method to provide the transformation * logic. If the return value is itself a Message, it will be used as the diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/MessageProducerSupportTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/MessageProducerSupportTests.java index dbffdbc47b7..ab0b74eba43 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/MessageProducerSupportTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/MessageProducerSupportTests.java @@ -202,6 +202,11 @@ protected void doStop() { this.stopped.set(true); } + @Override + public String getComponentType() { + return "custom-endpoint"; + } + } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/MessageHandlerChainTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/MessageHandlerChainTests.java index 5329a90dcc1..75a31c37124 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/MessageHandlerChainTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/MessageHandlerChainTests.java @@ -185,6 +185,11 @@ public void handleMessage(Message message) { output.send(message); } + @Override + public String getComponentType() { + return "producer"; + } + } } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractConnectionFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractConnectionFactory.java index 0b54e23dcf8..bb6829bf73f 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractConnectionFactory.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/AbstractConnectionFactory.java @@ -165,6 +165,11 @@ public ApplicationEventPublisher getApplicationEventPublisher() { return this.applicationEventPublisher; } + @Override + public String getComponentType() { + return "connection-factory"; + } + /** * Sets socket attributes on the socket. * @param socket The socket. diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactory.java index 0a91eedfb07..0d4bf738f73 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactory.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactory.java @@ -140,7 +140,7 @@ public void setComponentName(String componentName) { } @Override - public @Nullable String getComponentType() { + public String getComponentType() { return this.targetConnectionFactory.getComponentType(); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/ThreadAffinityClientConnectionFactory.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/ThreadAffinityClientConnectionFactory.java index 913a111ecde..aa66f20b7fa 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/ThreadAffinityClientConnectionFactory.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/ThreadAffinityClientConnectionFactory.java @@ -106,7 +106,7 @@ public void setApplicationEventPublisher(ApplicationEventPublisher applicationEv } @Override - public @Nullable String getComponentType() { + public String getComponentType() { return this.connectionFactory.getComponentType(); } diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MBeanExporterIntegrationTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MBeanExporterIntegrationTests.java index f194c52578f..97b9b35deee 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MBeanExporterIntegrationTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MBeanExporterIntegrationTests.java @@ -302,6 +302,11 @@ protected void doStart() { protected void doStop() { } + @Override + public String getComponentType() { + return "bogus-endpoint"; + } + } public static class DateFactoryBean implements FactoryBean { diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java index ff7bf8f9497..33c1ebc8bbc 100755 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java @@ -674,6 +674,11 @@ public String toString() { return this.url != null ? this.url.toString() : urlName; } + @Override + public String getComponentType() { + return "mail-receiver"; + } + @Nullable Store getStore() { return this.store; } diff --git a/spring-integration-test/src/test/java/org/springframework/integration/test/mock/CachedSpringIntegrationTestAnnotationTests.java b/spring-integration-test/src/test/java/org/springframework/integration/test/mock/CachedSpringIntegrationTestAnnotationTests.java index ba58c9d99ce..b2c29a276a6 100644 --- a/spring-integration-test/src/test/java/org/springframework/integration/test/mock/CachedSpringIntegrationTestAnnotationTests.java +++ b/spring-integration-test/src/test/java/org/springframework/integration/test/mock/CachedSpringIntegrationTestAnnotationTests.java @@ -77,6 +77,11 @@ public static BeanFactoryPostProcessor tesBeanFactoryPostProcessor() { public AbstractEndpoint someEndpoint() { return new AbstractEndpoint() { + @Override + public String getComponentType() { + return "some-endpoint"; + } + @Override protected void doStart() {