INT-705 Add support for 'order' on JMS 'outbound-channel-adapter' and 'outbound-gateway' elements.

This commit is contained in:
Mark Fisher
2009-07-03 04:04:46 +00:00
parent 2f1b8a7039
commit 1536b3c539
6 changed files with 155 additions and 0 deletions

View File

@@ -156,6 +156,15 @@
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="order" type="xsd:string">
<xsd:annotation>
<xsd:documentation><![CDATA[
Specifies the order for invocation when this endpoint is connected as a
subscriber to a SubscribableChannel.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="auto-startup" type="xsd:string"/>
</xsd:complexType>
<xsd:element name="file-to-string-transformer">

View File

@@ -29,6 +29,12 @@
delete-source-files="true"
directory="${java.io.tmpdir}"/>
<file:outbound-channel-adapter id="adapterWithOrder"
channel="testChannel"
order="555"
auto-startup="false"
directory="${java.io.tmpdir}"/>
<bean id="customFileNameGenerator" class="org.springframework.integration.file.config.CustomFileNameGenerator"/>
<context:property-placeholder/>

View File

@@ -53,6 +53,10 @@ public class FileOutboundChannelAdapterParserTests {
@Qualifier("adapterWithDeleteFlag")
EventDrivenConsumer adapterWithDeleteFlag;
@Autowired
@Qualifier("adapterWithOrder")
EventDrivenConsumer adapterWithOrder;
@Test
public void simpleAdapter() {
@@ -88,4 +92,19 @@ public class FileOutboundChannelAdapterParserTests {
assertEquals(Boolean.TRUE, handlerAccessor.getPropertyValue("deleteSourceFiles"));
}
@Test
public void adapterWithOrder() {
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapterWithOrder);
FileWritingMessageHandler handler = (FileWritingMessageHandler)
adapterAccessor.getPropertyValue("handler");
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
assertEquals(555, handlerAccessor.getPropertyValue("order"));
}
@Test
public void adapterWithAutoStartupFalse() {
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapterWithOrder);
assertEquals(Boolean.FALSE, adapterAccessor.getPropertyValue("autoStartup"));
}
}

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/integration/file"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd">
<si:channel id="copyInput" />
<si:channel id="moveInput" />
<si:channel id="output">
<si:queue capacity="1" />
</si:channel>
<outbound-gateway id="copier"
request-channel="copyInput"
reply-channel="output"
directory="${java.io.tmpdir}/anyDir" />
<outbound-gateway id="mover"
request-channel="moveInput"
reply-channel="output"
directory="${java.io.tmpdir}/anyDir"
delete-source-files="true"/>
<outbound-gateway id="ordered"
request-channel="someChannel"
reply-channel="output"
directory="${java.io.tmpdir}/anyDir"
auto-startup="false"
order="777"/>
<context:property-placeholder />
</beans:beans>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/integration/file"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd">
<outbound-gateway id="ordered"
request-channel="someChannel"
directory="${java.io.tmpdir}"
auto-startup="false"
order="777"/>
<context:property-placeholder />
</beans:beans>

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.file.config;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.integration.file.FileWritingMessageHandler;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class FileOutboundGatewayParserTests {
@Autowired
private ApplicationContext context;
@Test
public void checkOrderedGateway() throws Exception {
Object gateway = context.getBean("ordered");
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
FileWritingMessageHandler handler = (FileWritingMessageHandler)
gatewayAccessor.getPropertyValue("handler");
assertEquals(Boolean.FALSE, gatewayAccessor.getPropertyValue("autoStartup"));
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
assertEquals(777, handlerAccessor.getPropertyValue("order"));
}
}