Merge branch 'master' of git.springsource.org:spring-integration/spring-integration
This commit is contained in:
@@ -31,6 +31,7 @@ import org.springframework.util.StringUtils;
|
||||
public class SplitterFactoryBean extends AbstractMessageHandlerFactoryBean {
|
||||
|
||||
private volatile Long sendTimeout;
|
||||
private volatile boolean requiresReply;
|
||||
|
||||
public void setSendTimeout(Long sendTimeout) {
|
||||
this.sendTimeout = sendTimeout;
|
||||
@@ -64,7 +65,14 @@ public class SplitterFactoryBean extends AbstractMessageHandlerFactoryBean {
|
||||
if (this.sendTimeout != null) {
|
||||
splitter.setSendTimeout(sendTimeout);
|
||||
}
|
||||
splitter.setRequiresReply(requiresReply);
|
||||
return splitter;
|
||||
}
|
||||
public boolean isRequiresReply() {
|
||||
return requiresReply;
|
||||
}
|
||||
|
||||
public void setRequiresReply(boolean requiresReply) {
|
||||
this.requiresReply = requiresReply;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@ import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -38,7 +41,10 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess
|
||||
@SuppressWarnings("unchecked")
|
||||
protected final Object handleRequestMessage(Message<?> message) {
|
||||
Object result = this.splitMessage(message);
|
||||
if (result == null) {
|
||||
// return null if 'null', empty Collection or empty Array
|
||||
if ( result == null ||
|
||||
(result instanceof Collection && CollectionUtils.isEmpty((Collection<?>)result)) ||
|
||||
(result.getClass().isArray() && ObjectUtils.isEmpty((Object[]) result)) ) {
|
||||
return null;
|
||||
}
|
||||
MessageHeaders headers = message.getHeaders();
|
||||
@@ -59,10 +65,6 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess
|
||||
List<MessageBuilder<?>> messageBuilders = new ArrayList<MessageBuilder<?>>();
|
||||
if (result instanceof Collection) {
|
||||
Collection<?> items = (Collection<?>) result;
|
||||
//TODO put this return statement in a more obvious place
|
||||
if(items.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
int sequenceNumber = 0;
|
||||
int sequenceSize = items.size();
|
||||
for (Object item : items) {
|
||||
|
||||
@@ -1948,6 +1948,15 @@ Name of the header whose value to use.
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="expressionOrInnerEndpointDefinitionAware">
|
||||
<xsd:attributeGroup ref="inputOutputChannelGroup" />
|
||||
<xsd:attribute name="requires-reply" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Specify whether the splitter method must return a non-null value. This value will be
|
||||
FALSE by default, but if set to TRUE, a MessageHandlingException will be thrown when
|
||||
the underlying service method (or expression) returns a NULL value.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
@@ -19,13 +19,19 @@ package org.springframework.integration.router.config;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessageHandlingException;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -88,5 +94,14 @@ public class SplitterParserTests {
|
||||
assertEquals("test", result4.getPayload());
|
||||
assertNull(output.receive(0));
|
||||
}
|
||||
|
||||
@Test(expected=MessageHandlingException.class)
|
||||
public void splitterParserTestWithRequiresReply() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"splitterParserTests.xml", this.getClass());
|
||||
context.start();
|
||||
DirectChannel inputChannel = context.getBean("requiresReplyInput", DirectChannel.class);
|
||||
inputChannel.send(MessageBuilder.withPayload(Collections.emptyList()).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
ref="splitterImpl"
|
||||
input-channel="splitterImplementationInput"
|
||||
output-channel="output"/>
|
||||
|
||||
<splitter id="splitterImplementationRequiresReply"
|
||||
input-channel="requiresReplyInput"
|
||||
output-channel="output"
|
||||
requires-reply="true"/>
|
||||
|
||||
<beans:bean id="splitterBean" class="org.springframework.integration.router.config.TestSplitterBean"/>
|
||||
|
||||
|
||||
@@ -16,6 +16,17 @@
|
||||
|
||||
package org.springframework.integration.splitter;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
@@ -23,15 +34,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Iwein Fuld
|
||||
@@ -104,5 +106,4 @@ public class DefaultSplitterTests {
|
||||
Message<?> output = replyChannel.receive(15);
|
||||
assertThat(output, is(nullValue()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-parent</artifactId>
|
||||
@@ -23,7 +24,7 @@
|
||||
<org.hamcrest.version>1.1</org.hamcrest.version>
|
||||
<org.slf4j.version>1.5.10</org.slf4j.version>
|
||||
<org.springframework.version>3.0.3.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>2.0.5.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.security.version>3.0.3.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.ws.version>1.5.9</org.springframework.ws.version>
|
||||
</properties>
|
||||
<profiles>
|
||||
@@ -101,7 +102,8 @@
|
||||
</profiles>
|
||||
<distributionManagement>
|
||||
<!-- see 'staging' profile for dry-run deployment settings -->
|
||||
<!-- see 'snapshot', 'milestone' and 'release' profiles for respective repository settings -->
|
||||
<!-- see 'snapshot', 'milestone' and 'release' profiles for respective
|
||||
repository settings -->
|
||||
<downloadUrl>http://static.springframework.org/spring-integration/site/downloads/releases.html</downloadUrl>
|
||||
<site>
|
||||
<id>static.springframework.org</id>
|
||||
@@ -109,14 +111,10 @@
|
||||
</site>
|
||||
</distributionManagement>
|
||||
<dependencyManagement>
|
||||
<!--
|
||||
inheritable <dependency> declarations for child poms. children still
|
||||
must explicitly declare the groupId/artifactId of these dependencies
|
||||
in order for them to show up on the classpath, but metadata like
|
||||
<version> and <scope> are inherited, which cuts down on verbosity.
|
||||
see
|
||||
http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-dep-manage.html
|
||||
-->
|
||||
<!-- inheritable <dependency> declarations for child poms. children still
|
||||
must explicitly declare the groupId/artifactId of these dependencies in order
|
||||
for them to show up on the classpath, but metadata like <version> and <scope>
|
||||
are inherited, which cuts down on verbosity. see http://www.sonatype.com/books/mvnref-book/reference/pom-relationships-sect-dep-manage.html -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
@@ -213,13 +211,21 @@
|
||||
<artifactId>spring-commons-serializer</artifactId>
|
||||
<version>1.0.0.M1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
<version>${org.springframework.security.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
<version>${org.springframework.security.version}</version>
|
||||
</dependency>
|
||||
<!-- test-scoped dependencies -->
|
||||
<dependency>
|
||||
<!--
|
||||
while cglib is not necessarily a 'test'-related dependency, it is
|
||||
only used for testing purposes by child modules thus it's scope has
|
||||
been generalized to 'test' here
|
||||
-->
|
||||
<!-- while cglib is not necessarily a 'test'-related dependency, it is
|
||||
only used for testing purposes by child modules thus it's scope has been
|
||||
generalized to 'test' here -->
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib-nodep</artifactId>
|
||||
<version>${cglib.version}</version>
|
||||
@@ -276,12 +282,10 @@
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<!--
|
||||
dependency definitions to be inherited by child poms. any
|
||||
<dependency> declarations here will automatically show up on child
|
||||
project classpaths. only items that are truly common across all
|
||||
projects should go here. otherwise, consider <dependencyManagement />
|
||||
-->
|
||||
<!-- dependency definitions to be inherited by child poms. any <dependency>
|
||||
declarations here will automatically show up on child project classpaths.
|
||||
only items that are truly common across all projects should go here. otherwise,
|
||||
consider <dependencyManagement /> -->
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
@@ -292,10 +296,8 @@
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<!--
|
||||
available only in the springframework maven repository. see
|
||||
<repositories> section below
|
||||
-->
|
||||
<!-- available only in the springframework maven repository. see <repositories>
|
||||
section below -->
|
||||
<groupId>org.springframework.build.aws</groupId>
|
||||
<artifactId>org.springframework.build.aws.maven</artifactId>
|
||||
<version>3.0.0.RELEASE</version>
|
||||
@@ -376,12 +378,9 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!--
|
||||
configures the springsource bundlor plugin, which generates
|
||||
OSGI-compatible MANIFEST.MF files during the 'compile' phase of
|
||||
the maven build. For more information, see
|
||||
http://static.springsource.org/s2-bundlor/1.0.x/user-guide/html/ch04s03.html
|
||||
-->
|
||||
<!-- configures the springsource bundlor plugin, which generates OSGI-compatible
|
||||
MANIFEST.MF files during the 'compile' phase of the maven build. For more
|
||||
information, see http://static.springsource.org/s2-bundlor/1.0.x/user-guide/html/ch04s03.html -->
|
||||
<groupId>com.springsource.bundlor</groupId>
|
||||
<artifactId>com.springsource.bundlor.maven</artifactId>
|
||||
<version>1.0.0.RELEASE</version>
|
||||
@@ -398,10 +397,8 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!--
|
||||
configures the jar plugin to pick up the manifest created by
|
||||
bundlor (see above)
|
||||
-->
|
||||
<!-- configures the jar plugin to pick up the manifest created by bundlor
|
||||
(see above) -->
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
@@ -416,11 +413,8 @@
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<!--
|
||||
significantly speeds up the 'Dependencies' report during site
|
||||
creation see
|
||||
http://old.nabble.com/Skipping-dependency-report-during-Maven2-site-generation-td20116761.html
|
||||
-->
|
||||
<!-- significantly speeds up the 'Dependencies' report during site creation
|
||||
see http://old.nabble.com/Skipping-dependency-report-during-Maven2-site-generation-td20116761.html -->
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
<version>3.0.3.RELEASE</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework</groupId>
|
||||
@@ -38,7 +37,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
<version>3.0.3.RELEASE</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework</groupId>
|
||||
|
||||
Reference in New Issue
Block a user