INT-1874 the control-bus element is now allowed in a chain

This commit is contained in:
Mark Fisher
2011-04-22 09:10:21 -04:00
parent 6b08d2adfa
commit 222cf7acbb
3 changed files with 106 additions and 7 deletions

View File

@@ -1111,6 +1111,7 @@ endpoint itself is a Polling Consumer for a channel with a queue.
<xsd:element name="json-to-object-transformer" type="json-to-object-transformer-type" />
<xsd:element name="claim-check-in" type="claimCheckTransformerType" />
<xsd:element name="claim-check-out" type="claimCheckTransformerType" />
<xsd:element name="control-bus" type="control-bus-type" />
<xsd:element name="chain" type="chain-type" />
</xsd:choice>
</xsd:complexType>
@@ -2883,6 +2884,19 @@ The list of component name patterns you want to track (e.g., tracked-components
</xsd:element>
<xsd:element name="control-bus">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="control-bus-type">
<xsd:all minOccurs="0" maxOccurs="1">
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
</xsd:all>
<xsd:attributeGroup ref="inputOutputChannelGroup" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="control-bus-type">
<xsd:annotation>
<xsd:documentation><![CDATA[
Control bus that accepts messages in the form of SpEL expressions. The expressions should be provided
@@ -2894,13 +2908,7 @@ The list of component name patterns you want to track (e.g., tracked-components
3) get/set or shutdown methods on configurable TaskExecutors or TaskSchedulers
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:all minOccurs="0" maxOccurs="1">
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
</xsd:all>
<xsd:attributeGroup ref="inputOutputChannelGroup" />
</xsd:complexType>
</xsd:element>
</xsd:complexType>
<xsd:attributeGroup name="inputOutputChannelGroup">
<xsd:attribute name="id" type="xsd:ID" />

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:groovy="http://www.springframework.org/schema/integration/groovy"
xsi:schemaLocation="http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<channel id="output">
<queue/>
</channel>
<chain input-channel="input" output-channel="output">
<control-bus/>
</chain>
<beans:bean id="service" class="org.springframework.integration.config.xml.ControlBusChainTests$Service" />
</beans:beans>

View File

@@ -0,0 +1,72 @@
/*
* Copyright 2002-2011 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.config.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.util.Date;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class ControlBusChainTests {
@Autowired
private MessageChannel input;
@Autowired
private PollableChannel output;
@Test
public void testDefaultEvaluationContext() {
Message<?> message = MessageBuilder.withPayload("@service.convert('aardvark')+headers.foo").setHeader("foo", "bar").build();
this.input.send(message);
assertEquals("catbar", output.receive(0).getPayload());
assertNull(output.receive(0));
}
public static class Service {
@ManagedOperation
public String convert(String input) {
return "cat";
}
}
public static class AdapterService {
public Message<String> receive() {
return new GenericMessage<String>(new Date().toString());
}
}
}