From fd107168dffe812cf810adddbc05766c9a0c29ed Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Thu, 24 Dec 2009 00:35:17 +0000 Subject: [PATCH] INT-937 added toString implementation to MethodInvokingMessageProcessor --- .../MethodInvokingMessageProcessor.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MethodInvokingMessageProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MethodInvokingMessageProcessor.java index 53b9e2958a..95102e86fe 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MethodInvokingMessageProcessor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MethodInvokingMessageProcessor.java @@ -67,6 +67,8 @@ public class MethodInvokingMessageProcessor implements MessageProcessor { private final Object targetObject; + private volatile String displayString; + private volatile boolean requiresReply; private final Map, HandlerMethod> handlerMethods; @@ -98,9 +100,11 @@ public class MethodInvokingMessageProcessor implements MessageProcessor { private MethodInvokingMessageProcessor(Object targetObject, Class annotationType, Method method) { Assert.notNull(method, "method must not be null"); HandlerMethod handlerMethod = new HandlerMethod(method); + Assert.notNull(targetObject, "targetObject must not be null"); this.targetObject = targetObject; this.handlerMethods = Collections., HandlerMethod>singletonMap(handlerMethod.getTargetParameterType(), handlerMethod); this.evaluationContext = this.createEvaluationContext(targetObject, method, annotationType); + this.setDisplayString(targetObject, method); } private MethodInvokingMessageProcessor(Object targetObject, Class annotationType, String methodName) { @@ -108,13 +112,26 @@ public class MethodInvokingMessageProcessor implements MessageProcessor { } private MethodInvokingMessageProcessor(Object targetObject, Class annotationType, String methodName, boolean requiresReply) { + Assert.notNull(targetObject, "targetObject must not be null"); this.targetObject = targetObject; this.requiresReply = requiresReply; this.handlerMethods = this.findHandlerMethodsForTarget(targetObject, annotationType, methodName, requiresReply); this.evaluationContext = this.createEvaluationContext(targetObject, methodName, annotationType); + this.setDisplayString(targetObject, methodName); } + private void setDisplayString(Object targetObject, Object targetMethod) { + StringBuilder sb = new StringBuilder(targetObject.getClass().getName()); + if (targetMethod instanceof Method) { + sb.append("." + ((Method) targetMethod).getName()); + } + else if (targetMethod instanceof String) { + sb.append("." + (String) targetMethod); + } + this.displayString = sb.toString() + "]"; + } + private EvaluationContext createEvaluationContext(Object targetObject, Object method, Class annotationType) { StandardEvaluationContext context = new StandardEvaluationContext(); // TODO: StandardEvaluationContext may soon provide a better way to *replace* the MethodResolver @@ -138,6 +155,10 @@ public class MethodInvokingMessageProcessor implements MessageProcessor { } + public String toString() { + return this.displayString; + } + public Object processMessage(Message message) { EvaluationException evaluationException = null; List candidates = this.findHandlerMethodsForMessage(message);