From 4b2fbace61dbf20b536557dbae8a3bf5c21ae314 Mon Sep 17 00:00:00 2001 From: David Turanski Date: Wed, 13 Jul 2011 22:11:00 -0400 Subject: [PATCH] Fixed properties resolution issue --- .../flow/ChannelNamePortConfiguration.java | 8 ------ .../integration/flow/Flow.java | 28 ++++++++----------- .../flows/subflow2/subflow2-context.xml | 2 +- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/springframework/integration/flow/ChannelNamePortConfiguration.java b/src/main/java/org/springframework/integration/flow/ChannelNamePortConfiguration.java index 33a1032..1be7838 100644 --- a/src/main/java/org/springframework/integration/flow/ChannelNamePortConfiguration.java +++ b/src/main/java/org/springframework/integration/flow/ChannelNamePortConfiguration.java @@ -57,14 +57,6 @@ public class ChannelNamePortConfiguration implements PortConfiguration { for (PortMetadata portMetadata : outputPortMetadataList ) { results.add(portMetadata.getPortName()); } - /** - * consistent with ClientPortConfiguration impl. - */ - - if (results.isEmpty()) { - return null; - } - return results; } diff --git a/src/main/java/org/springframework/integration/flow/Flow.java b/src/main/java/org/springframework/integration/flow/Flow.java index 1a82dd6..c6b07ee 100644 --- a/src/main/java/org/springframework/integration/flow/Flow.java +++ b/src/main/java/org/springframework/integration/flow/Flow.java @@ -10,7 +10,6 @@ import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertiesPropertySource; @@ -37,9 +36,9 @@ public class Flow implements InitializingBean, BeanNameAware, ChannelResolver, A private static Log logger = LogFactory.getLog(Flow.class); - private volatile ConfigurableApplicationContext flowContext; + private volatile ClassPathXmlApplicationContext flowContext; - private ConfigurableApplicationContext applicationContext; + private ApplicationContext applicationContext; private volatile FlowConfiguration flowConfiguration; @@ -92,22 +91,22 @@ public class Flow implements InitializingBean, BeanNameAware, ChannelResolver, A Assert.notEmpty(configLocations, "configLocations cannot be empty"); - flowContext = new ClassPathXmlApplicationContext(configLocations, applicationContext); - - this.flowConfiguration = flowContext.getBean(FlowConfiguration.class); - Assert.notNull(flowConfiguration, "flow context does not contain a flow configuration"); + flowContext = new ClassPathXmlApplicationContext(applicationContext); + addReferencedProperties(); + + this.flowContext.setConfigLocations(configLocations); + + this.flowContext.refresh(); + this.flowConfiguration = flowContext.getBean(FlowConfiguration.class); + Assert.notNull(flowConfiguration, "flow context does not contain a flow configuration"); validatePortMapping(); this.flowChannelResolver = new BeanFactoryChannelResolver(flowContext); - - addReferencedProperties(); - - bridgeMessagingPorts(); - + bridgeMessagingPorts(); } @@ -157,13 +156,10 @@ public class Flow implements InitializingBean, BeanNameAware, ChannelResolver, A private void addReferencedProperties() { if (flowProperties != null) { - PropertySource propertySource = new PropertiesPropertySource("flowProperties", flowProperties); MutablePropertySources propertySources = flowContext.getEnvironment().getPropertySources(); propertySources.addLast(propertySource); - - this.flowContext.refresh(); } } @@ -195,7 +191,7 @@ public class Flow implements InitializingBean, BeanNameAware, ChannelResolver, A @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = (ConfigurableApplicationContext) applicationContext; + this.applicationContext = applicationContext; } } diff --git a/src/test/resources/META-INF/spring/integration/flows/subflow2/subflow2-context.xml b/src/test/resources/META-INF/spring/integration/flows/subflow2/subflow2-context.xml index 493921b..85509df 100644 --- a/src/test/resources/META-INF/spring/integration/flows/subflow2/subflow2-context.xml +++ b/src/test/resources/META-INF/spring/integration/flows/subflow2/subflow2-context.xml @@ -12,7 +12,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> - +