updated for scripting namespace
This commit is contained in:
@@ -12,7 +12,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionValidationException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
@@ -124,7 +123,6 @@ public class Flow implements InitializingBean, BeanNameAware, ChannelResolver, A
|
||||
|
||||
Assert.notEmpty(configLocations, "configLocations cannot be empty");
|
||||
|
||||
|
||||
/*
|
||||
* create a child application context
|
||||
*/
|
||||
@@ -140,7 +138,7 @@ public class Flow implements InitializingBean, BeanNameAware, ChannelResolver, A
|
||||
this.flowContext.setConfigLocations(configLocations);
|
||||
|
||||
this.flowContext.refresh();
|
||||
|
||||
|
||||
// Deep debug
|
||||
// FlowUtils.displayBeansGraph(flowContext.getBeanFactory());
|
||||
//
|
||||
@@ -245,26 +243,28 @@ public class Flow implements InitializingBean, BeanNameAware, ChannelResolver, A
|
||||
"flow configuration contains no port configurations");
|
||||
|
||||
/*
|
||||
* Verify that no channels in the flow context are shared in the parent context
|
||||
* Verify that no channels in the flow context are shared in the parent
|
||||
* context
|
||||
*/
|
||||
List<String> errors = new ArrayList<String>();
|
||||
|
||||
|
||||
List<String> channelNames = Arrays.asList(this.flowContext.getBeanNamesForType(MessageChannel.class));
|
||||
|
||||
Set<String> referencedMessageChannels = FlowUtils.getReferencedMessageChannels(this.flowContext.getBeanFactory());
|
||||
|
||||
for (String referencedMessageChannel: referencedMessageChannels) {
|
||||
|
||||
Set<String> referencedMessageChannels = FlowUtils.getReferencedMessageChannels(this.flowContext
|
||||
.getBeanFactory());
|
||||
|
||||
for (String referencedMessageChannel : referencedMessageChannels) {
|
||||
if (!channelNames.contains(referencedMessageChannel)) {
|
||||
errors.add("Flow references channel [" + referencedMessageChannel + "] defined in the parent context. " +
|
||||
"This channel should be explicitly defined in the flow context");
|
||||
errors.add("Flow references channel [" + referencedMessageChannel + "] defined in the parent context. "
|
||||
+ "This channel should be explicitly defined in the flow context");
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.size() > 0 ) {
|
||||
throw new BeanDefinitionValidationException("\n"+StringUtils.arrayToDelimitedString(errors.toArray(),"\n"));
|
||||
|
||||
if (errors.size() > 0) {
|
||||
throw new BeanDefinitionValidationException("\n"
|
||||
+ StringUtils.arrayToDelimitedString(errors.toArray(), "\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void bridgeMessagingPorts() {
|
||||
/*
|
||||
@@ -288,4 +288,8 @@ public class Flow implements InitializingBean, BeanNameAware, ChannelResolver, A
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public ApplicationContext getFlowContext() {
|
||||
return this.flowContext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.springframework.integration.flow.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
|
||||
public class BarFactory implements FactoryBean<Bar> {
|
||||
|
||||
@Override
|
||||
public Bar getObject() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return new Bar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getObjectType() {
|
||||
// TODO Auto-generated method stub
|
||||
return Bar.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,22 @@
|
||||
package org.springframework.integration.flow.config.xml;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.flow.Flow;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:/FlowWithAutowireTest-context.xml")
|
||||
public class FlowWithAutowireTest {
|
||||
@Autowired
|
||||
Flow flow;
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
Foo foo = flow.getFlowContext().getBean(Foo.class);
|
||||
assertNotNull(foo.bar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package org.springframework.integration.flow.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
public class Foo {
|
||||
@Autowired
|
||||
Bar bar;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.springframework.integration.flow.config.xml;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
public class FooFactory implements FactoryBean<Foo>{
|
||||
|
||||
@Autowired
|
||||
Bar bar;
|
||||
@Override
|
||||
public Foo getObject() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
Foo foo = new Foo();
|
||||
foo.bar = bar;
|
||||
return foo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
// TODO Auto-generated method stub
|
||||
return Foo.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-flow="http://www.springframework.org/schema/integration/flow"
|
||||
xmlns:int-script="http://www.springframework.org/schema/integration/script"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-flow="http://www.springframework.org/schema/integration/flow"
|
||||
xmlns:int-script="http://www.springframework.org/schema/integration/scripting"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd
|
||||
http://www.springframework.org/schema/integration/script http://www.springframework.org/schema/integration/script-2.1.xsd
|
||||
http://www.springframework.org/schema/integration/flow http://www.springframework.org/schema/integration/flow/spring-integration-flow-2.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/script http://www.springframework.org/schema/integration/script-2.1.xsd
|
||||
http://www.springframework.org/schema/integration/scripting http://www.springframework.org/schema/integration/scripting/spring-integration-scripting.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
|
||||
|
||||
<int-flow:flow-configuration>
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean class="org.springframework.integration.flow.config.xml.Foo"/>
|
||||
<bean class="org.springframework.integration.flow.config.xml.FooFactory"/>
|
||||
<bean class="org.springframework.integration.flow.config.xml.Bar"/>
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user