Example usage for org.springframework.integration.context IntegrationContextUtils INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME

List of usage examples for org.springframework.integration.context IntegrationContextUtils INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME

Introduction

In this page you can find the example usage for org.springframework.integration.context IntegrationContextUtils INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME.

Prototype

String INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME

To view the source code for org.springframework.integration.context IntegrationContextUtils INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME.

Click Source Link

Usage

From source file:org.springframework.integration.config.IntegrationRegistrar.java

/**
 * Register a {@link DefaultHeaderChannelRegistry} in the given {@link BeanDefinitionRegistry}, if necessary.
 * @param registry The {@link BeanDefinitionRegistry} to register additional {@link BeanDefinition}s.
 */// www.j av a  2s  .c o m
private void registerHeaderChannelRegistry(BeanDefinitionRegistry registry) {
    boolean alreadyRegistered = false;
    if (registry instanceof ListableBeanFactory) {
        alreadyRegistered = ((ListableBeanFactory) registry)
                .containsBean(IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME);
    } else {
        alreadyRegistered = registry
                .isBeanNameInUse(IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME);
    }
    if (!alreadyRegistered) {
        if (logger.isInfoEnabled()) {
            logger.info(
                    "No bean named '" + IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME
                            + "' has been explicitly defined. "
                            + "Therefore, a default DefaultHeaderChannelRegistry will be created.");
        }
        BeanDefinitionBuilder schedulerBuilder = BeanDefinitionBuilder
                .genericBeanDefinition(DefaultHeaderChannelRegistry.class);
        BeanDefinitionHolder replyChannelRegistryComponent = new BeanDefinitionHolder(
                schedulerBuilder.getBeanDefinition(),
                IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME);
        BeanDefinitionReaderUtils.registerBeanDefinition(replyChannelRegistryComponent, registry);
    }
}

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 {/*from   w  w w .java  2  s .  c  om*/
        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);
    }
}