Example usage for org.springframework.messaging.core DestinationResolutionException DestinationResolutionException

List of usage examples for org.springframework.messaging.core DestinationResolutionException DestinationResolutionException

Introduction

In this page you can find the example usage for org.springframework.messaging.core DestinationResolutionException DestinationResolutionException.

Prototype

public DestinationResolutionException(@Nullable String description, @Nullable Throwable cause) 

Source Link

Usage

From source file:org.springframework.integration.support.channel.BeanFactoryChannelResolver.java

@Override
public MessageChannel resolveDestination(String name) {
    Assert.state(this.beanFactory != null, "BeanFactory is required");
    try {/*ww w  .j a va  2 s  .  co  m*/
        return this.beanFactory.getBean(name, MessageChannel.class);
    } catch (BeansException e) {
        if (!(e instanceof NoSuchBeanDefinitionException)) {
            throw new DestinationResolutionException(
                    "A bean definition with name '" + name + "' exists, but failed to be created", e);
        }
        if (!this.initialized) {
            synchronized (this) {
                if (!this.initialized) {
                    try {
                        this.replyChannelRegistry = this.beanFactory.getBean(
                                IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME,
                                HeaderChannelRegistry.class);
                    } catch (Exception ex) {
                        logger.debug("No HeaderChannelRegistry found");
                    }
                    this.initialized = true;
                }
            }
        }
        if (this.replyChannelRegistry != null) {
            MessageChannel channel = this.replyChannelRegistry.channelNameToChannel(name);
            if (channel != null) {
                return channel;
            }
        }
        throw new DestinationResolutionException(
                "failed to look up MessageChannel with name '" + name + "' in the BeanFactory"
                        + (this.replyChannelRegistry == null
                                ? " (and there is no HeaderChannelRegistry present)."
                                : "."),
                e);
    }
}