INT-2501: Set CI#autoCreate from INT properties

JIRA: https://jira.springsource.org/browse/INT-2501
This commit is contained in:
Artem Bilan
2013-11-21 19:54:52 +02:00
parent d0501cda4d
commit 6a2583affd
6 changed files with 11 additions and 3 deletions

View File

@@ -47,6 +47,7 @@ import org.springframework.integration.channel.DefaultHeaderChannelRegistry;
import org.springframework.integration.config.IntegrationEvaluationContextFactoryBean;
import org.springframework.integration.config.xml.ChannelInitializer.AutoCreateCandidatesCollector;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.context.IntegrationProperties;
import org.springframework.integration.expression.IntegrationEvaluationContextAwareBeanPostProcessor;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -145,7 +146,10 @@ public abstract class AbstractIntegrationNamespaceHandler implements NamespaceHa
alreadyRegistered = parserContext.getRegistry().isBeanNameInUse(CHANNEL_INITIALIZER_BEAN_NAME);
}
if (!alreadyRegistered) {
BeanDefinitionBuilder channelDef = BeanDefinitionBuilder.genericBeanDefinition(ChannelInitializer.class);
String channelsAutoCreateExpression = "#{@" +IntegrationContextUtils.INTEGRATION_PROPERTIES_BEAN_NAME +
"['" + IntegrationProperties.CHANNELS_AUTOCREATE + "']}";
BeanDefinitionBuilder channelDef = BeanDefinitionBuilder.genericBeanDefinition(ChannelInitializer.class)
.addPropertyValue("autoCreate", channelsAutoCreateExpression);
BeanDefinitionHolder channelCreatorHolder = new BeanDefinitionHolder(channelDef.getBeanDefinition(), CHANNEL_INITIALIZER_BEAN_NAME);
BeanDefinitionReaderUtils.registerBeanDefinition(channelCreatorHolder, parserContext.getRegistry());
}

View File

@@ -26,4 +26,6 @@ public interface IntegrationProperties {
String LATE_REPLY_LOGGING_LEVEL = "messagingTemplate.lateReply.logging.level";
String CHANNELS_AUTOCREATE = "channels.autoCreate";
}

View File

@@ -1 +1,2 @@
channels.autoCreate=true
messagingTemplate.lateReply.logging.level=warn

View File

@@ -7,7 +7,7 @@
<int:service-activator input-channel="inputChannel" expression="'hello'"/>
<bean id="ChannelInitializer" class="org.springframework.integration.config.xml.ChannelInitializer">
<bean id="channelInitializer" class="org.springframework.integration.config.xml.ChannelInitializer">
<property name="autoCreate" value="true"/>
</bean>

View File

@@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
<bean id="ChannelInitializer" class="org.springframework.integration.config.xml.ChannelInitializer">
<bean id="channelInitializer" class="org.springframework.integration.config.xml.ChannelInitializer">
<property name="autoCreate" value="true"/>
</bean>

View File

@@ -1 +1,2 @@
#channels.autoCreate=false
messagingTemplate.lateReply.logging.level=error