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

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

Introduction

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

Prototype

String INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME

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

Click Source Link

Usage

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

/**
 * Register {@code integrationGlobalProperties} bean if necessary.
 * @param registry The {@link BeanDefinitionRegistry} to register additional {@link BeanDefinition}s.
 *///from  www.  ja  va2 s  .c om
private void registerIntegrationProperties(BeanDefinitionRegistry registry) {
    boolean alreadyRegistered = false;
    if (registry instanceof ListableBeanFactory) {
        alreadyRegistered = ((ListableBeanFactory) registry)
                .containsBean(IntegrationContextUtils.INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME);
    } else {
        alreadyRegistered = registry
                .isBeanNameInUse(IntegrationContextUtils.INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME);
    }
    if (!alreadyRegistered) {
        ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(this.classLoader);
        try {
            Resource[] defaultResources = resourceResolver
                    .getResources("classpath*:META-INF/spring.integration.default.properties");
            Resource[] userResources = resourceResolver
                    .getResources("classpath*:META-INF/spring.integration.properties");

            List<Resource> resources = new LinkedList<Resource>(Arrays.asList(defaultResources));
            resources.addAll(Arrays.asList(userResources));

            BeanDefinitionBuilder integrationPropertiesBuilder = BeanDefinitionBuilder
                    .genericBeanDefinition(PropertiesFactoryBean.class)
                    .addPropertyValue("locations", resources);

            registry.registerBeanDefinition(IntegrationContextUtils.INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME,
                    integrationPropertiesBuilder.getBeanDefinition());
        } catch (IOException e) {
            logger.warn("Cannot load 'spring.integration.properties' Resources.", e);
        }
    }
}