diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/SplitterFactoryBean.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/SplitterFactoryBean.java
index f4418ea065..64c21aaa33 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/SplitterFactoryBean.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/SplitterFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * 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.
@@ -30,19 +30,32 @@ import org.springframework.util.StringUtils;
*/
public class SplitterFactoryBean extends AbstractMessageHandlerFactoryBean {
+ private Long sendTimeout;
+
+ public void setSendTimeout(Long sendTimeout) {
+ this.sendTimeout = sendTimeout;
+ }
+
@Override
protected MessageHandler createHandler(Object targetObject, String targetMethodName) {
+ AbstractMessageSplitter splitter = null;
if (targetObject == null) {
Assert.isTrue(!StringUtils.hasText(targetMethodName),
"'method' should only be provided when 'ref' is also provided");
- return new DefaultMessageSplitter();
+ splitter = new DefaultMessageSplitter();
}
- if (targetObject instanceof AbstractMessageSplitter) {
- return (AbstractMessageSplitter) targetObject;
+ else if (targetObject instanceof AbstractMessageSplitter) {
+ splitter = (AbstractMessageSplitter) targetObject;
}
- return (StringUtils.hasText(targetMethodName))
- ? new MethodInvokingSplitter(targetObject, targetMethodName)
- : new MethodInvokingSplitter(targetObject);
+ else {
+ splitter = (StringUtils.hasText(targetMethodName))
+ ? new MethodInvokingSplitter(targetObject, targetMethodName)
+ : new MethodInvokingSplitter(targetObject);
+ }
+ if (this.sendTimeout != null) {
+ splitter.setSendTimeout(this.sendTimeout.longValue());
+ }
+ return splitter;
}
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/TransformerFactoryBean.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/TransformerFactoryBean.java
index 072ad2be4e..7d702ee75f 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/TransformerFactoryBean.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/TransformerFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * 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.
@@ -30,6 +30,12 @@ import org.springframework.util.StringUtils;
*/
public class TransformerFactoryBean extends AbstractMessageHandlerFactoryBean {
+ private Long sendTimeout;
+
+ public void setSendTimeout(Long sendTimeout) {
+ this.sendTimeout = sendTimeout;
+ }
+
@Override
protected MessageHandler createHandler(Object targetObject, String targetMethodName) {
Assert.notNull(targetObject, "targetObject must not be null");
@@ -43,7 +49,11 @@ public class TransformerFactoryBean extends AbstractMessageHandlerFactoryBean {
else {
transformer = new MethodInvokingTransformer(targetObject);
}
- return new MessageTransformingHandler(transformer);
+ MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
+ if (this.sendTimeout != null) {
+ handler.setSendTimeout(this.sendTimeout.longValue());
+ }
+ return handler;
}
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/FilterParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/FilterParser.java
index b636b85319..3c6a7e91e1 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/FilterParser.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/FilterParser.java
@@ -38,7 +38,8 @@ public class FilterParser extends AbstractConsumerEndpointParser {
IntegrationNamespaceUtils.BASE_PACKAGE + ".filter.MessageFilter");
builder.addConstructorArgReference((String) this.parseSelector(element, parserContext));
-
+
+ IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "discard-channel");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "throw-exception-on-rejection");
return builder;
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/ServiceActivatorParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/ServiceActivatorParser.java
index 4511c27626..2b11b99953 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/ServiceActivatorParser.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/ServiceActivatorParser.java
@@ -52,6 +52,7 @@ public class ServiceActivatorParser extends AbstractConsumerEndpointParser {
String method = element.getAttribute(METHOD_ATTRIBUTE);
builder.getRawBeanDefinition().getConstructorArgumentValues().addGenericArgumentValue(method, "java.lang.String");
}
+ IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
return builder;
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/SplitterParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/SplitterParser.java
index 203516bdc0..960a08de4f 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/SplitterParser.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/SplitterParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * 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.
@@ -38,7 +38,8 @@ public class SplitterParser extends AbstractConsumerEndpointParser {
IntegrationNamespaceUtils.BASE_PACKAGE + ".config.SplitterFactoryBean");
if (innerDefinition != null){
builder.addPropertyValue("targetObject", innerDefinition);
- } else if (element.hasAttribute(REF_ATTRIBUTE)) {
+ }
+ else if (element.hasAttribute(REF_ATTRIBUTE)) {
String ref = element.getAttribute(REF_ATTRIBUTE);
builder.addPropertyReference("targetObject", ref);
if (StringUtils.hasText(element.getAttribute(METHOD_ATTRIBUTE))) {
@@ -46,6 +47,7 @@ public class SplitterParser extends AbstractConsumerEndpointParser {
builder.addPropertyValue("targetMethodName", method);
}
}
+ IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
return builder;
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/TransformerParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/TransformerParser.java
index 0de4af65cf..bad024f730 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/TransformerParser.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/TransformerParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * 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.
@@ -38,7 +38,8 @@ public class TransformerParser extends AbstractConsumerEndpointParser {
if (innerDefinition != null){
builder.addPropertyValue("targetObject", innerDefinition);
- } else {
+ }
+ else {
String ref = element.getAttribute(REF_ATTRIBUTE);
if (!StringUtils.hasText(ref)) {
parserContext.getReaderContext().error("Either \"ref\" attribute or inner bean () definition of concrete implementation of " +
@@ -52,6 +53,8 @@ public class TransformerParser extends AbstractConsumerEndpointParser {
if (StringUtils.hasText(method)) {
builder.addPropertyValue("targetMethodName", method);
}
+ IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
return builder;
}
+
}
diff --git a/org.springframework.integration/src/main/resources/org/springframework/integration/config/xml/spring-integration-1.0.xsd b/org.springframework.integration/src/main/resources/org/springframework/integration/config/xml/spring-integration-1.0.xsd
index d19b57f66a..710a724a2d 100644
--- a/org.springframework.integration/src/main/resources/org/springframework/integration/config/xml/spring-integration-1.0.xsd
+++ b/org.springframework.integration/src/main/resources/org/springframework/integration/config/xml/spring-integration-1.0.xsd
@@ -479,6 +479,14 @@
+
+
+
+ Specify the maximum amount of time in milliseconds to wait when sending reply
+ Messages to the output channel. By default the send will block for one second.
+
+
+
@@ -1251,7 +1259,6 @@
-
-
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/handler/SendTimeoutConfigurationTests-context.xml b/org.springframework.integration/src/test/java/org/springframework/integration/handler/SendTimeoutConfigurationTests-context.xml
new file mode 100644
index 0000000000..1806da5660
--- /dev/null
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/handler/SendTimeoutConfigurationTests-context.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/handler/SendTimeoutConfigurationTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/handler/SendTimeoutConfigurationTests.java
new file mode 100644
index 0000000000..f57f17c4f8
--- /dev/null
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/handler/SendTimeoutConfigurationTests.java
@@ -0,0 +1,86 @@
+/*
+ * 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.handler;
+
+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.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author Mark Fisher
+ */
+@ContextConfiguration
+@RunWith(SpringJUnit4ClassRunner.class)
+public class SendTimeoutConfigurationTests {
+
+ @Autowired
+ private ApplicationContext context;
+
+
+ @Test
+ public void serviceActivator() {
+ assertEquals(123, this.getTimeout("serviceActivator"));
+ }
+
+ @Test
+ public void filter() {
+ assertEquals(123, this.getTimeout("filter"));
+ }
+
+ @Test
+ public void transformer() {
+ assertEquals(123, this.getTimeout("transformer"));
+ }
+
+ @Test
+ public void splitter() {
+ assertEquals(123, this.getTimeout("splitter"));
+ }
+
+ @Test
+ public void router() {
+ assertEquals(123, this.getTimeout("router"));
+ }
+
+
+ private long getTimeout(String endpointName) {
+ DirectFieldAccessor endpointAccessor = new DirectFieldAccessor(context.getBean(endpointName));
+ DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(endpointAccessor.getPropertyValue("handler"));
+ DirectFieldAccessor templateAccessor = new DirectFieldAccessor(handlerAccessor.getPropertyValue("channelTemplate"));
+ return ((Long) templateAccessor.getPropertyValue("sendTimeout")).longValue();
+ }
+
+
+ static class TestBean {
+
+ public boolean filter(String s) {
+ return true;
+ }
+
+ public String echo(String s) {
+ return s;
+ }
+ }
+
+}