|
32 | 32 |
|
33 | 33 | import org.springframework.beans.BeansException; |
34 | 34 | import org.springframework.beans.factory.BeanClassLoaderAware; |
| 35 | +import org.springframework.beans.factory.BeanFactory; |
| 36 | +import org.springframework.beans.factory.HierarchicalBeanFactory; |
35 | 37 | import org.springframework.beans.factory.SmartInitializingSingleton; |
36 | 38 | import org.springframework.beans.factory.config.BeanDefinition; |
37 | 39 | import org.springframework.beans.factory.config.BeanDefinitionHolder; |
|
79 | 81 | * @author Oleg Zhurakousky |
80 | 82 | * @author Artem Bilan |
81 | 83 | * @author Gary Russell |
| 84 | + * @author Michael Wiles |
82 | 85 | * |
83 | 86 | * @see IntegrationContextUtils |
84 | 87 | */ |
@@ -151,18 +154,20 @@ public void afterSingletonsInstantiated() { |
151 | 154 | private void registerNullChannel() { |
152 | 155 | if (this.beanFactory.containsBean(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME)) { |
153 | 156 | BeanDefinition nullChannelDefinition = null; |
154 | | - if (this.beanFactory.containsBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME)) { |
155 | | - nullChannelDefinition = |
156 | | - this.beanFactory.getBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME); |
157 | | - } |
158 | | - else { |
159 | | - BeanDefinitionRegistry parentBeanFactory = |
160 | | - (BeanDefinitionRegistry) this.beanFactory.getParentBeanFactory(); |
161 | | - if (parentBeanFactory != null) { |
162 | | - nullChannelDefinition = |
163 | | - parentBeanFactory.getBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME); |
| 157 | + BeanFactory beanFactory = this.beanFactory; |
| 158 | + do { |
| 159 | + if (beanFactory instanceof ConfigurableListableBeanFactory) { |
| 160 | + ConfigurableListableBeanFactory listable = (ConfigurableListableBeanFactory) beanFactory; |
| 161 | + if (listable.containsBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME)) { |
| 162 | + nullChannelDefinition = listable |
| 163 | + .getBeanDefinition(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME); |
| 164 | + } |
| 165 | + } |
| 166 | + if (beanFactory instanceof HierarchicalBeanFactory) { |
| 167 | + beanFactory = ((HierarchicalBeanFactory) beanFactory).getParentBeanFactory(); |
164 | 168 | } |
165 | 169 | } |
| 170 | + while (nullChannelDefinition == null); |
166 | 171 |
|
167 | 172 | if (nullChannelDefinition != null && |
168 | 173 | !NullChannel.class.getName().equals(nullChannelDefinition.getBeanClassName())) { |
|
0 commit comments