From 1d7d9046ae911f7db9594d9c9741342a7cb9e2b8 Mon Sep 17 00:00:00 2001 From: Marius Bogoevici Date: Mon, 9 Jun 2008 20:27:55 +0000 Subject: [PATCH] http://jira.springframework.org/browse/INT-253 Reply-channel on a is now optional. If absent, a temporary RendezvousChannel will be created for this particular invocation (default bevaviour of the underlying RequestReplyTemplate). Also, a small fix for the corner case when a method like void doNothing() is called. In this case, nothing happens. --- .../config/spring-integration-core-1.0.xsd | 4 ++-- .../gateway/GatewayProxyFactoryBean.java | 22 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-core-1.0.xsd b/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-core-1.0.xsd index 42a95e61f1..826ad28c4f 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-core-1.0.xsd +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-core-1.0.xsd @@ -147,7 +147,7 @@ - + @@ -357,7 +357,7 @@ - + diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java b/org.springframework.integration/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java index 31a696e12d..8926f27ae6 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/gateway/GatewayProxyFactoryBean.java @@ -20,7 +20,6 @@ import java.lang.reflect.Method; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; - import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.support.AopUtils; import org.springframework.beans.SimpleTypeConverter; @@ -121,22 +120,27 @@ public class GatewayProxyFactoryBean extends SimpleMessagingGateway } Method method = invocation.getMethod(); Class returnType = method.getReturnType(); - boolean shouldReturnMessage = Message.class.isAssignableFrom(returnType); + boolean isReturnTypeMessage = Message.class.isAssignableFrom(returnType); + boolean shouldReply = returnType != void.class; int paramCount = method.getParameterTypes().length; Object response = null; if (paramCount == 0) { - if (shouldReturnMessage) { - return this.receive(); + if (shouldReply) { + if (isReturnTypeMessage) { + return this.receive(); + } + response = this.receive(); } - response = this.receive(); } else { Object payload = (paramCount == 1) ? invocation.getArguments()[0] : invocation.getArguments(); - if (returnType.equals(void.class)) { - this.send(payload); - return null; + if (shouldReply) { + response = isReturnTypeMessage ? this.sendAndReceiveMessage(payload) : this.sendAndReceive(payload); + } + else { + this.send(payload); + response = null; } - response = shouldReturnMessage ? this.sendAndReceiveMessage(payload) : this.sendAndReceive(payload); } return (response != null) ? this.typeConverter.convertIfNecessary(response, returnType) : null; }