diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelationStrategyAdapter.java b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelationStrategyAdapter.java
index 00f976c9e5..756eeb5c85 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelationStrategyAdapter.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelationStrategyAdapter.java
@@ -29,24 +29,23 @@ import org.springframework.util.Assert;
*/
public class CorrelationStrategyAdapter implements CorrelationStrategy {
- private final MessageMappingMethodInvoker invoker;
+ private final MessageMappingMethodInvoker invoker;
- public CorrelationStrategyAdapter(Object object, String methodName) {
- this.invoker = new MessageMappingMethodInvoker(object, methodName, true);
- }
+ public CorrelationStrategyAdapter(Object object, String methodName) {
+ this.invoker = new MessageMappingMethodInvoker(object, methodName, true);
+ }
- public CorrelationStrategyAdapter(Object object, Method method) {
- Assert.notNull(object, "'object' must not be null");
- Assert.notNull(method, "'method' must not be null");
- Assert.isTrue(method.getParameterTypes().length == 1, "Method must accept exactly one parameter");
- Assert.isTrue(!Void.TYPE.equals(method.getReturnType()), "Method return type must not be void");
- this.invoker = new MessageMappingMethodInvoker(object, method);
- }
+ public CorrelationStrategyAdapter(Object object, Method method) {
+ Assert.notNull(object, "'object' must not be null");
+ Assert.notNull(method, "'method' must not be null");
+ Assert.isTrue(method.getParameterTypes().length == 1, "Method must accept exactly one parameter");
+ Assert.isTrue(!Void.TYPE.equals(method.getReturnType()), "Method return type must not be void");
+ this.invoker = new MessageMappingMethodInvoker(object, method);
+ }
+ public Object getCorrelationKey(Message> message) {
+ return invoker.processMessage(message);
+ }
- public Object getCorrelationKey(Message> message) {
- return invoker.invokeMethod(message);
- }
-
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/filter/MethodInvokingSelector.java b/org.springframework.integration/src/main/java/org/springframework/integration/filter/MethodInvokingSelector.java
index 7dae7b84ae..ecc71730b9 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/filter/MethodInvokingSelector.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/filter/MethodInvokingSelector.java
@@ -47,7 +47,7 @@ public class MethodInvokingSelector implements MessageSelector {
public boolean accept(Message> message) {
- Object result = this.invoker.invokeMethod(message);
+ Object result = this.invoker.processMessage(message);
Assert.notNull(result, "result must not be null");
Assert.isAssignable(Boolean.class, result.getClass(), "a boolean result is required");
return (Boolean) result;
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageMappingMethodInvoker.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageMappingMethodInvoker.java
index d1eba9b842..53cb8810ca 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageMappingMethodInvoker.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageMappingMethodInvoker.java
@@ -50,7 +50,7 @@ import org.springframework.util.StringUtils;
* @author Marius Bogoevici
* @see MethodParameterMessageMapper
*/
-public class MessageMappingMethodInvoker {
+public class MessageMappingMethodInvoker implements MessageProcessor {
protected static final Log logger = LogFactory.getLog(MessageMappingMethodInvoker.class);
@@ -90,9 +90,8 @@ public class MessageMappingMethodInvoker {
this.object = object;
this.methodResolver = this.createResolverForMethodName(methodName, requiresReturnValue);
}
-
- public Object invokeMethod(Message> message) {
+ public Object processMessage(Message> message) {
Assert.notNull(message, "message must not be null");
if (message.getPayload() == null) {
if (logger.isDebugEnabled()) {
@@ -104,7 +103,7 @@ public class MessageMappingMethodInvoker {
Object[] args = null;
try {
args = this.createArgumentArrayFromMessage(method, message);
- return this.doInvokeMethod(method, args, message);
+ return this.invokeMethod(method, args, message);
}
catch (InvocationTargetException e) {
if (e.getCause() != null && e.getCause() instanceof RuntimeException) {
@@ -122,7 +121,7 @@ public class MessageMappingMethodInvoker {
}
}
- private Object doInvokeMethod(Method method, Object[] args, Message> message) throws Exception {
+ private Object invokeMethod(Method method, Object[] args, Message> message) throws Exception {
Object result = null;
MethodInvoker invoker = null;
try {
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageProcessor.java
new file mode 100644
index 0000000000..17a1eb2eeb
--- /dev/null
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageProcessor.java
@@ -0,0 +1,49 @@
+/*
+ * 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 org.springframework.integration.core.Message;
+
+/**
+ * This defines the lowest-level strategy of processing a Message and returning
+ * some Object (or null). Implementations will be focused on generic concerns,
+ * such as invoking a method, running a script, or evaluating an expression.
+ *
+ * Higher level MessageHandler implementations can delegate to these processors
+ * for such functionality, but it is the responsibility of each handler type to
+ * add the semantics such as routing, splitting, transforming, etc.
+ *
+ * In some cases the return value might be a Message itself, but it does not
+ * need to be. It is the responsibility of the caller to determine how to treat
+ * the return value. That may require creating a Message or even creating
+ * multiple Messages from that value.
+ *
+ * This strategy and its various implementations are considered part of the
+ * internal "support" API, intended for use by Spring Integration's various
+ * message-handling components. As such, it is subject to change.
+ *
+ * @author Mark Fisher
+ * @since 2.0
+ */
+public interface MessageProcessor {
+
+ /**
+ * Process the Message and return a value (or null).
+ */
+ Object processMessage(Message> message);
+
+}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MethodInvokingMessageHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MethodInvokingMessageHandler.java
index a72ac07aa0..6c50b0a864 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MethodInvokingMessageHandler.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MethodInvokingMessageHandler.java
@@ -54,7 +54,7 @@ public class MethodInvokingMessageHandler extends MessageMappingMethodInvoker im
}
public void handleMessage(Message> message) {
- Object result = this.invokeMethod(message);
+ Object result = this.processMessage(message);
if (result != null) {
throw new MessagingException(message, "the MethodInvokingMessageHandler method must "
+ "have a void return, but '" + this + "' received a value: [" + result + "]");
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java
index cfbe38205a..16e241c5c8 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java
@@ -46,7 +46,7 @@ public class ServiceActivatingHandler extends AbstractReplyProducingMessageHandl
@Override
protected void handleRequestMessage(Message> message, ReplyMessageHolder replyHolder) {
try {
- Object result = this.invoker.invokeMethod(message);
+ Object result = this.invoker.processMessage(message);
if (result != null) {
replyHolder.set(result);
}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/router/MethodInvokingRouter.java b/org.springframework.integration/src/main/java/org/springframework/integration/router/MethodInvokingRouter.java
index 0742c18458..94fcd6147d 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/router/MethodInvokingRouter.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/router/MethodInvokingRouter.java
@@ -54,7 +54,7 @@ public class MethodInvokingRouter extends AbstractChannelNameResolvingMessageRou
@Override
protected List