INT-3319 Fix BeanFactory Propagation
JIRA: https://jira.spring.io/browse/INT-3319 The `MessageBuilderFactory` abstraction relies on the bean factory being propagated to all classes that create messages. Some classes were missed in the initial PR.
This commit is contained in:
committed by
Artem Bilan
parent
1c9bcaccee
commit
75af72a77c
@@ -18,6 +18,7 @@ package org.springframework.integration.redis.channel;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
@@ -33,7 +34,6 @@ import org.springframework.integration.MessageDispatchingException;
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.MessagePublishingErrorHandler;
|
||||
import org.springframework.integration.context.IntegrationProperties;
|
||||
import org.springframework.integration.dispatcher.AbstractDispatcher;
|
||||
import org.springframework.integration.dispatcher.BroadcastingDispatcher;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.support.converter.SimpleMessageConverter;
|
||||
@@ -60,7 +60,7 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final String topicName;
|
||||
|
||||
private final AbstractDispatcher dispatcher = new BroadcastingDispatcher(true);
|
||||
private final BroadcastingDispatcher dispatcher = new BroadcastingDispatcher(true);
|
||||
|
||||
private volatile Integer maxSubscribers;
|
||||
|
||||
@@ -84,6 +84,7 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
this.taskExecutor = taskExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMessageConverter(MessageConverter messageConverter) {
|
||||
Assert.notNull(messageConverter, "'messageConverter' must not be null");
|
||||
this.messageConverter = messageConverter;
|
||||
@@ -135,6 +136,9 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
if (this.messageConverter == null){
|
||||
this.messageConverter = new SimpleMessageConverter();
|
||||
}
|
||||
if (this.messageConverter instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageConverter).setBeanFactory(this.getBeanFactory());
|
||||
}
|
||||
this.container.setConnectionFactory(connectionFactory);
|
||||
if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor)) {
|
||||
ErrorHandler errorHandler = new MessagePublishingErrorHandler(
|
||||
@@ -147,6 +151,7 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
adapter.afterPropertiesSet();
|
||||
this.container.addMessageListener(adapter, new ChannelTopic(topicName));
|
||||
this.container.afterPropertiesSet();
|
||||
this.dispatcher.setBeanFactory(this.getBeanFactory());
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2013 the original author or authors
|
||||
* Copyright 2007-2014 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.redis.inbound;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.listener.ChannelTopic;
|
||||
import org.springframework.data.redis.listener.PatternTopic;
|
||||
@@ -95,6 +96,9 @@ public class RedisInboundChannelAdapter extends MessageProducerSupport {
|
||||
}
|
||||
Assert.state(hasTopics || hasPatterns, "at least one topic or topic pattern is required for subscription.");
|
||||
|
||||
if (this.messageConverter instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageConverter).setBeanFactory(this.getBeanFactory());
|
||||
}
|
||||
MessageListenerDelegate delegate = new MessageListenerDelegate();
|
||||
MessageListenerAdapter adapter = new MessageListenerAdapter(delegate);
|
||||
adapter.setSerializer(this.serializer);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.redis.outbound;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
@@ -94,6 +95,9 @@ public class RedisPublishingMessageHandler extends AbstractMessageHandler implem
|
||||
@Override
|
||||
protected void onInit() throws Exception {
|
||||
Assert.notNull(topicExpression, "'topicExpression' must not be null.");
|
||||
if (this.messageConverter instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageConverter).setBeanFactory(this.getBeanFactory());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user