Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ public void run() {
}
}

@Override
public String getComponentType() {
return "header-channel-registry";
}

protected record MessageChannelWrapper(MessageChannel channel, long expireAt) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ public Message<?> toMessage(Object payload, @Nullable MessageHeaders headers) {
}
}

@Override
public String getComponentType() {
return "converter";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: this is not an IntegrationObjectSupport.
But separate story.

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ else if (conversionService.canConvert(key.getClass(), String.class)) {
}
}

@Override
public String getComponentType() {
return "router-mapping-provider";
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public void setTransactionSynchronizationFactory(
this.transactionSynchronizationFactory = transactionSynchronizationFactory;
}

@Override
public String getComponentType() {
return "polling-endpoint";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SourcePollingChannelAdapter does provide an impl of this method.
So, another one - PollingConsumer - has to do that as well: polling-consumer.

}

/**
* Return the default error channel if the error handler is explicitly provided and
* it is a {@link MessagePublishingErrorHandler}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,9 @@ private void logComponentSubscriptionEvent(boolean add) {
}
}

@Override
public String getComponentType() {
return "event-driven";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, event-driven-consumer to be precise.

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ public void setOutputChannelName(String outputChannelName) {
return this.outputChannel;
}

@Override
public String getComponentType() {
return "message-producer";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think neither of abstract class should provide an impl.
That is really responsibility of the specific one.
Without an implementation here, we may spot a bug somewhere down the hierarchy, e.g. ReactiveMessageSourceProducer.

}

public void setErrorChannel(MessageChannel errorChannel) {
this.errorChannel = errorChannel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ protected void doStop() {
}
}

@Override
public String getComponentType() {
return "reactive-streams";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reactive-streams-consumer ?

}

private static final class MessageHandlerSubscriber
implements CoreSubscriber<Message<?>>, Disposable, Lifecycle {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,9 +53,10 @@ public class BeanFactoryChannelResolver implements DestinationResolver<MessageCh

private final Lock lock = new ReentrantLock();

@SuppressWarnings("NullAway.Init")
private BeanFactory beanFactory;

private HeaderChannelRegistry replyChannelRegistry;
private @Nullable HeaderChannelRegistry replyChannelRegistry;

private volatile boolean initialized;

Expand Down Expand Up @@ -89,7 +91,6 @@ public void setBeanFactory(BeanFactory beanFactory) {

@Override
public MessageChannel resolveDestination(String name) {
Assert.state(this.beanFactory != null, "BeanFactory is required");
try {
return this.beanFactory.getBean(name, MessageChannel.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.springframework.integration.support.channel;

import org.jspecify.annotations.Nullable;

import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.messaging.MessageChannel;
Expand All @@ -37,7 +39,7 @@ public interface HeaderChannelRegistry {
* @param channel The channel.
* @return The channel name, or the channel if it is not a MessageChannel.
*/
Object channelToChannelName(Object channel);
@Nullable Object channelToChannelName(Object channel);

/**
* Converts the channel to a name (String). If the channel is not a
Expand All @@ -48,15 +50,15 @@ public interface HeaderChannelRegistry {
* @return The channel name, or the channel if it is not a MessageChannel.
* @since 4.1
*/
Object channelToChannelName(Object channel, long timeToLive);
@Nullable Object channelToChannelName(Object channel, long timeToLive);

/**
* Converts the channel name back to a {@link MessageChannel} (if it is
* registered).
* @param name The name of the channel.
* @return The channel, or null if there is no channel registered with the name.
*/
MessageChannel channelNameToChannel(String name);
@Nullable MessageChannel channelNameToChannel(String name);

/**
* @return the current size of the registry
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Provides classes supporting use of the channel.
*/
@org.jspecify.annotations.NullMarked
package org.springframework.integration.support.channel;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* Provides classes supporting use of the application context.
*/
@org.jspecify.annotations.NullMarked
package org.springframework.integration.support.context;
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class AllowListDeserializingConverter implements Converter<byte[], Object

private final Deserializer<Object> deserializer;

@Nullable
private final ClassLoader defaultDeserializerClassLoader;
private final @Nullable ClassLoader defaultDeserializerClassLoader;

private final boolean usingDefaultDeserializer;

Expand Down Expand Up @@ -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. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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");
Expand All @@ -119,7 +118,6 @@ public Message<?> toMessage(Object object, @Nullable MessageHeaders messageHeade
.build();
}

@Nullable
@Override
public Object fromMessage(Message<?> message, Class<?> clazz) {
Map<String, Object> map = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class SimpleMessageConverter implements MessageConverter, BeanFactoryAwar

private boolean messageBuilderFactorySet;

private BeanFactory beanFactory;
private @Nullable BeanFactory beanFactory;

public SimpleMessageConverter() {
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -132,7 +130,7 @@ private class DefaultInboundMessageMapper implements InboundMessageMapper<Object
}

@Override
public Message<?> toMessage(@Nullable Object object, @Nullable Map<String, Object> headers) {
public @Nullable Message<?> toMessage(@Nullable Object object, @Nullable Map<String, Object> headers) {
if (object == null) {
return null;
}
Expand All @@ -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();
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public void processAfterRollback(IntegrationResourceHolder holder) {
doProcess(holder, this.afterRollbackExpression, this.afterRollbackChannel, "afterRollback");
}

@Override
public String getComponentType() {
return "processor";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one also must not be an IntegrationObjectSupport.

}

private void doProcess(IntegrationResourceHolder holder, Expression expression,
@Nullable MessageChannel messageChannel, String expressionType) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ protected void doStop() {
this.stopped.set(true);
}

@Override
public String getComponentType() {
return "custom-endpoint";
}

}

}
Loading
Loading