SimpleMethodInvoker now delegates to an ArgumentConvertingMethodInvoker.

This commit is contained in:
Mark Fisher
2008-04-03 18:15:31 +00:00
parent d3b28c7da6
commit 70e365f4dd
4 changed files with 71 additions and 3 deletions

View File

@@ -71,6 +71,18 @@ public class MessageEndpointAnnotationPostProcessorTests {
context.stop();
}
@Test
public void testTypeConvertingHandler() throws InterruptedException {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("typeConvertingEndpointTests.xml", this.getClass());
context.start();
MessageChannel inputChannel = (MessageChannel) context.getBean("inputChannel");
MessageChannel outputChannel = (MessageChannel) context.getBean("outputChannel");
inputChannel.send(new StringMessage("123"));
Message<?> message = outputChannel.receive(1000);
assertEquals(246, message.getPayload());
context.stop();
}
@Test
public void testPolledAnnotation() throws InterruptedException {
MessageBus messageBus = new MessageBus();

View File

@@ -0,0 +1,33 @@
/*
* Copyright 2002-2008 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.endpoint.annotation;
import org.springframework.integration.annotation.Handler;
import org.springframework.integration.annotation.MessageEndpoint;
/**
* @author Mark Fisher
*/
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel", pollPeriod=10)
public class TypeConvertingTestEndpoint {
@Handler
public int multiplyByTwo(int number) {
return number * 2;
}
}

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:integration="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd">
<bean id="bus" class="org.springframework.integration.bus.MessageBus"/>
<integration:channel id="inputChannel"/>
<integration:channel id="outputChannel"/>
<bean id="endpoint" class="org.springframework.integration.endpoint.annotation.TypeConvertingTestEndpoint"/>
<bean class="org.springframework.integration.config.MessageEndpointAnnotationPostProcessor">
<constructor-arg ref="bus"/>
</bean>
</beans>