/*
 * Copyright 2002-2013 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.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.messaging.core;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.Assert;


/**
 * @author Mark Fisher
 * @since 4.0
 */
public class BeanFactoryMessageChannelDestinationResolver implements DestinationResolver<MessageChannel> {

	private final BeanFactory beanFactory;


	public BeanFactoryMessageChannelDestinationResolver(BeanFactory beanFactory) {
		Assert.notNull(beanFactory, "beanFactory must not be null");
		this.beanFactory = beanFactory;
	}


	@Override
	public MessageChannel resolveDestination(String name) {
		Assert.state(this.beanFactory != null, "BeanFactory is required");
		try {
			return this.beanFactory.getBean(name, MessageChannel.class);
		}
		catch (BeansException e) {
			throw new DestinationResolutionException(
					"failed to look up MessageChannel bean with name '" + name + "'", e);
		}
	}

}

@@ -762,16 +762,75 @@
 actory;%0A
+import org.springframework.beans.factory.BeanFactoryAware;%0A
 import o
@@ -1069,53 +1069,1060 @@
 nel%3E
- %7B%0A%0A%09private final BeanFactory beanFactory;%0A%0A
+, BeanFactoryAware %7B%0A%0A%09private volatile BeanFactory beanFactory;%0A%0A%09/**%0A%09 * Create a new instance of the %7B@link%0A%09 * BeanFactoryMessageChannelDestinationResolver%7D class.%0A%09 * %3Cp%3EThe BeanFactory to access must be set via %3Ccode%3EsetBeanFactory%3C/code%3E.%0A%09 * This will happen automatically if this resolver is defined within an%0A%09 * ApplicationContext thereby receiving the callback upon initialization.%0A%09 *%0A%09 * @see #setBeanFactory%0A%09 */%0A%09public BeanFactoryMessageChannelDestinationResolver() %7B%0A%0A%09%7D%0A%0A%09/**%0A%09 * Create a new instance of the %7B@link%0A%09 * BeanFactoryMessageChannelDestinationResolver%7D class.%0A%09 * %3Cp%3EUse of this constructor is redundant if this object is being created%0A%09 * by a Spring IoC container as the supplied %7B@link BeanFactory%7D will be%0A%09 * replaced by the %7B@link BeanFactory%7D that creates it (c.f. the%0A%09 * %7B@link BeanFactoryAware%7D contract). So only use this constructor if you%0A%09 * are instantiating this object explicitly rather than defining a bean.%0A%09 *%0A%09 * @param beanFactory the bean factory to be used to lookup %7B@link MessageChannel%7Ds.%0A%09 */
 %0A%09pu
@@ -2670,10 +2670,136 @@
 %09%09%7D%0A%09%7D%0A%0A
+%09@Override%0A%09public void setBeanFactory(BeanFactory beanFactory) throws BeansException %7B%0A%09%09this.beanFactory = beanFactory;%0A%09%7D%0A%0A
 %7D%0A

Make BeanFactoryMCDR BeanFactoryAware