From cb8b4bca52b51ac63ee5790dc3ab182f759a5542 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 20 Nov 2019 14:23:29 -0500 Subject: [PATCH] Fix TcpConnectionFactory FactoryBean - bean factory and application context were not injected - `afterPropertiesSet()` was not called **cherry-pick to all supported branches** # Conflicts: # spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBean.java --- .../TcpConnectionFactoryFactoryBean.java | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBean.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBean.java index f84ce36258..c98aaca9fe 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBean.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBean.java @@ -18,10 +18,11 @@ package org.springframework.integration.ip.config; import java.util.concurrent.Executor; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.context.Lifecycle; @@ -58,7 +59,7 @@ import org.springframework.util.Assert; * @since 2.0.5 */ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean - implements Lifecycle, BeanNameAware, BeanFactoryAware, ApplicationEventPublisherAware { + implements Lifecycle, BeanNameAware, ApplicationEventPublisherAware, ApplicationContextAware { private volatile AbstractConnectionFactory connectionFactory; @@ -76,7 +77,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean getObjectType() { return this.connectionFactory != null ? this.connectionFactory.getClass() : - this.type == null ? AbstractConnectionFactory.class : - isServer() ? AbstractServerConnectionFactory.class : - isClient() ? AbstractClientConnectionFactory.class : - AbstractConnectionFactory.class; + this.type == null ? AbstractConnectionFactory.class : + isServer() ? AbstractServerConnectionFactory.class : + isClient() ? AbstractClientConnectionFactory.class : + AbstractConnectionFactory.class; } @Override protected AbstractConnectionFactory createInstance() throws Exception { if (!this.mapperSet) { - this.mapper.setBeanFactory(this.beanFactory); + this.mapper.setBeanFactory(getBeanFactory()); } if (this.usingNio) { if (isServer()) { @@ -194,6 +196,11 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean