MessageMappingMethodInvoker now delegates to an instance of HandlerMethodResolver. Multiple annotated methods or method name matches are possible, and in such cases, the Method-resolution will occur at runtime based on the payload type of the Message to be handled (INT-72 and INT-191).

This commit is contained in:
Mark Fisher
2008-11-18 19:42:56 +00:00
parent 38e3fae8c1
commit 8ca2c3227b
7 changed files with 94 additions and 115 deletions

View File

@@ -104,7 +104,6 @@ public class CorrelationIdTests {
MethodInvokingSplitter splitter = new MethodInvokingSplitter(
new TestBean(), TestBean.class.getMethod("split", String.class));
splitter.setOutputChannel(testChannel);
splitter.afterPropertiesSet();
splitter.handleMessage(message);
Message<?> reply1 = testChannel.receive(100);
Message<?> reply2 = testChannel.receive(100);

View File

@@ -70,8 +70,7 @@ public class MethodInvokingSelectorTests {
public void noArgMethodWithMethodReference() throws Exception {
TestBean testBean = new TestBean();
Method method = testBean.getClass().getMethod("noArgs", new Class[] {});
MethodInvokingSelector selector = new MethodInvokingSelector(testBean, method);
selector.accept(new StringMessage("test"));
new MethodInvokingSelector(testBean, method);
}
@Test(expected = IllegalArgumentException.class)

View File

@@ -42,14 +42,12 @@ public class MethodInvokingMessageHandlerTests {
@Test
public void validMethod() {
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(new TestSink(), "validMethod");
handler.afterPropertiesSet();
handler.handleMessage(new GenericMessage<String>("test"));
}
@Test(expected = IllegalArgumentException.class)
public void invalidMethodWithNoArgs() {
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(new TestSink(), "invalidMethodWithNoArgs");
handler.afterPropertiesSet();
new MethodInvokingMessageHandler(new TestSink(), "invalidMethodWithNoArgs");
}
@Test(expected = MessagingException.class)
@@ -57,7 +55,6 @@ public class MethodInvokingMessageHandlerTests {
Message<?> message = new StringMessage("test");
try {
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(new TestSink(), "methodWithReturnValue");
handler.afterPropertiesSet();
handler.handleMessage(message);
}
catch (MessagingException e) {
@@ -68,8 +65,7 @@ public class MethodInvokingMessageHandlerTests {
@Test(expected = IllegalArgumentException.class)
public void noMatchingMethodName() {
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(new TestSink(), "noSuchMethod");
handler.afterPropertiesSet();
new MethodInvokingMessageHandler(new TestSink(), "noSuchMethod");
}
@Test

View File

@@ -396,8 +396,8 @@ public class MethodInvokingSplitterTests {
}
@Test(expected = IllegalArgumentException.class)
public void multipleAnnotations() {
new MethodInvokingSplitter(new MultipleAnnotationTestBean());
public void ambiguousTypeMatch() {
new MethodInvokingSplitter(new AmbiguousTypeMatchTestBean());
}
@Test
@@ -515,7 +515,7 @@ public class MethodInvokingSplitterTests {
}
public static class MultipleAnnotationTestBean {
public static class AmbiguousTypeMatchTestBean {
@Splitter
public String[] method1(String input) {