diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/MethodInvokingAggregator.java b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/MethodInvokingAggregator.java index 56ae3fc7b3..845d40c61e 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/MethodInvokingAggregator.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/MethodInvokingAggregator.java @@ -16,16 +16,19 @@ package org.springframework.integration.aggregator; +import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; +import org.springframework.aop.support.AopUtils; +import org.springframework.core.annotation.AnnotationUtils; import org.springframework.integration.annotation.Aggregator; import org.springframework.integration.core.Message; import org.springframework.integration.message.GenericMessage; -import org.springframework.integration.util.DefaultMethodResolver; -import org.springframework.integration.util.MethodResolver; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; +import org.springframework.util.ReflectionUtils; /** * {@link AbstractMessageAggregator} adapter for methods annotated with @@ -37,8 +40,6 @@ import org.springframework.util.CollectionUtils; */ public class MethodInvokingAggregator extends AbstractMessageAggregator { - private final MethodResolver methodResolver = new DefaultMethodResolver(Aggregator.class); - private final MessageListMethodAdapter methodInvoker; @@ -52,7 +53,7 @@ public class MethodInvokingAggregator extends AbstractMessageAggregator { public MethodInvokingAggregator(Object object) { Assert.notNull(object, "object must not be null"); - Method method = this.methodResolver.findMethod(object); + Method method = this.findAggregatorMethod(object); Assert.notNull(method, "unable to resolve Aggregator method on target class [" + object.getClass() + "]"); this.methodInvoker = new MessageListMethodAdapter(object, method); @@ -73,4 +74,46 @@ public class MethodInvokingAggregator extends AbstractMessageAggregator { return new GenericMessage(returnedValue); } + + private Method findAggregatorMethod(Object candidate) { + Class targetClass = AopUtils.getTargetClass(candidate); + if (targetClass == null) { + targetClass = candidate.getClass(); + } + Method method = this.findAnnotatedMethod(targetClass); + if (method == null) { + method = this.findSinglePublicMethod(targetClass); + } + return method; + } + + private Method findAnnotatedMethod(final Class targetClass) { + final AtomicReference annotatedMethod = new AtomicReference(); + ReflectionUtils.doWithMethods(targetClass, new ReflectionUtils.MethodCallback() { + public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { + Annotation annotation = AnnotationUtils.findAnnotation(method, Aggregator.class); + if (annotation != null) { + Assert.isNull(annotatedMethod.get(), "found more than one method on target class [" + + targetClass + "] with the annotation type [" + Aggregator.class.getName() + "]"); + annotatedMethod.set(method); + } + } + }); + return annotatedMethod.get(); + } + + private Method findSinglePublicMethod(Class targetClass) { + Method result = null; + for (Method method : targetClass.getMethods()) { + if (!method.getDeclaringClass().equals(Object.class)) { + if (result != null) { + throw new IllegalArgumentException( + "Class [" + targetClass + "] contains more than one public Method."); + } + result = method; + } + } + return result; + } + } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/util/AnnotationMethodResolver.java b/org.springframework.integration/src/main/java/org/springframework/integration/util/AnnotationMethodResolver.java deleted file mode 100644 index 85e777c1d1..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/util/AnnotationMethodResolver.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.util; - -import java.lang.annotation.Annotation; -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; -import java.lang.reflect.Method; -import java.util.concurrent.atomic.AtomicReference; - -import org.springframework.aop.support.AopUtils; -import org.springframework.core.annotation.AnnotationUtils; -import org.springframework.util.Assert; -import org.springframework.util.ObjectUtils; -import org.springframework.util.ReflectionUtils; - -/** - * MethodResolver implementation that finds a single Method on the - * given Class that contains the specified annotation type. - * - * @author Mark Fisher - */ -public class AnnotationMethodResolver implements MethodResolver { - - private Class annotationType; - - - /** - * Create a MethodResolver for the specified Method-level annotation type - */ - public AnnotationMethodResolver(Class annotationType) { - Assert.notNull(annotationType, "annotationType must not be null"); - Assert.isTrue(ObjectUtils.containsElement( - annotationType.getAnnotation(Target.class).value(), ElementType.METHOD), - "Annotation [" + annotationType + "] is not a Method-level annotation."); - this.annotationType = annotationType; - } - - - /** - * Find a single Method on the Class of the given candidate object - * that contains the annotation type for which this resolver is searching. - * - * @param candidate the instance whose Class will be checked for the - * annotation - * @param annotationType the Method-level annotation type - * - * @return a single matching Method instance or null if the - * candidate's Class contains no Methods with the specified annotation - * - * @throws IllegalArgumentException if more than one Method has the - * specified annotation - */ - public Method findMethod(Object candidate) { - Assert.notNull(candidate, "candidate object must not be null"); - Class targetClass = AopUtils.getTargetClass(candidate); - if (targetClass == null) { - targetClass = candidate.getClass(); - } - return this.findMethod(targetClass); - } - - /** - * Find a single Method on the given Class that contains the - * annotation type for which this resolver is searching. - * - * @param clazz the Class instance to check for the annotation - * @param annotationType the Method-level annotation type - * - * @return a single matching Method instance or null if the - * Class contains no Methods with the specified annotation - * - * @throws IllegalArgumentException if more than one Method has the - * specified annotation - */ - public Method findMethod(final Class clazz) { - Assert.notNull(clazz, "class must not be null"); - final AtomicReference annotatedMethod = new AtomicReference(); - ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() { - public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { - Annotation annotation = AnnotationUtils.findAnnotation(method, annotationType); - if (annotation != null) { - Assert.isNull(annotatedMethod.get(), "found more than one method on target class [" - + clazz + "] with the annotation type [" + annotationType + "]"); - annotatedMethod.set(method); - } - } - }); - return annotatedMethod.get(); - } - -} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/util/DefaultMethodResolver.java b/org.springframework.integration/src/main/java/org/springframework/integration/util/DefaultMethodResolver.java deleted file mode 100644 index 67cd71e173..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/util/DefaultMethodResolver.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.util; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; - -import org.springframework.aop.support.AopUtils; -import org.springframework.util.Assert; - -/** - * Default MethodResolver implementation. It first checks for a single Method - * with the specified annotation (if not null), and then falls back to a single - * public Method if available. - * - * @author Mark Fisher - */ -public class DefaultMethodResolver implements MethodResolver { - - private final AnnotationMethodResolver annotationMethodResolver; - - - public DefaultMethodResolver() { - this(null); - } - - public DefaultMethodResolver(Class annotationType) { - this.annotationMethodResolver = (annotationType != null) ? - new AnnotationMethodResolver(annotationType) : null; - } - - - public Method findMethod(Object candidate) { - Assert.notNull(candidate, "candidate object must not be null"); - Class targetClass = AopUtils.getTargetClass(candidate); - if (targetClass == null) { - targetClass = candidate.getClass(); - } - return this.findMethod(targetClass); - } - - public Method findMethod(Class clazz) { - if (this.annotationMethodResolver != null) { - Method method = this.annotationMethodResolver.findMethod(clazz); - if (method != null) { - return method; - } - } - return this.findSinglePublicMethod(clazz); - } - - private Method findSinglePublicMethod(Class clazz) { - Method result = null; - for (Method method : clazz.getMethods()) { - if (!method.getDeclaringClass().equals(Object.class)) { - if (result != null) { - throw new IllegalArgumentException( - "Class [" + clazz + "] contains more than one public Method."); - } - result = method; - } - } - return result; - } - -} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/util/MethodResolver.java b/org.springframework.integration/src/main/java/org/springframework/integration/util/MethodResolver.java deleted file mode 100644 index 84523cbedb..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/util/MethodResolver.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.util; - -import java.lang.reflect.Method; - -/** - * Strategy interface for detecting a single Method on a Class. - * - * @author Mark Fisher - */ -public interface MethodResolver { - - /** - * Find a single Method on the provided Object that matches this resolver's - * criteria. - * - * @param candidate the candidate Object whose Class should be searched for - * a Method - * - * @return a single Method or null if no Method matching this - * resolver's criteria can be found. - * - * @throws IllegalArgumentException if more than one Method defined on the - * given candidate's Class matches this resolver's criteria - */ - Method findMethod(Object candidate) throws IllegalArgumentException; - - /** - * Find a single Method on the given Class that matches this - * resolver's criteria. - * - * @param clazz the Class instance on which to search for a Method - * - * @return a single Method or null if no Method matching this - * resolver's criteria can be found. - * - * @throws IllegalArgumentException if more than one Method defined on the - * given Class matches this resolver's criteria - */ - Method findMethod(Class clazz); - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/aggregator/AggregatorMethodResolutionTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/aggregator/AggregatorMethodResolutionTests.java new file mode 100644 index 0000000000..83c0a0c5e7 --- /dev/null +++ b/org.springframework.integration/src/test/java/org/springframework/integration/aggregator/AggregatorMethodResolutionTests.java @@ -0,0 +1,205 @@ +/* + * 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.aggregator; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Method; +import java.util.List; + +import org.junit.Test; + +import org.springframework.aop.framework.ProxyFactory; +import org.springframework.beans.DirectFieldAccessor; +import org.springframework.integration.aggregator.MethodInvokingAggregator; +import org.springframework.integration.annotation.Aggregator; +import org.springframework.integration.channel.DirectChannel; +import org.springframework.integration.channel.QueueChannel; +import org.springframework.integration.core.Message; +import org.springframework.integration.endpoint.EventDrivenConsumer; +import org.springframework.integration.message.MessageBuilder; + +/** + * @author Mark Fisher + */ +public class AggregatorMethodResolutionTests { + + @Test + public void singleAnnotation() throws Exception { + SingleAnnotationTestBean bean = new SingleAnnotationTestBean(); + MethodInvokingAggregator aggregator = new MethodInvokingAggregator(bean); + Method method = this.getMethod(aggregator); + Method expected = SingleAnnotationTestBean.class.getMethod("method1", new Class[] { List.class }); + assertEquals(expected, method); + } + + @Test(expected = IllegalArgumentException.class) + public void multipleAnnotations() { + MultipleAnnotationTestBean bean = new MultipleAnnotationTestBean(); + new MethodInvokingAggregator(bean); + } + + @Test + public void noAnnotations() throws Exception { + NoAnnotationTestBean bean = new NoAnnotationTestBean(); + MethodInvokingAggregator aggregator = new MethodInvokingAggregator(bean); + Method method = this.getMethod(aggregator); + Method expected = NoAnnotationTestBean.class.getMethod("method1", new Class[] { List.class }); + assertEquals(expected, method); + } + + @Test(expected = IllegalArgumentException.class) + public void multiplePublicMethods() { + MultiplePublicMethodTestBean bean = new MultiplePublicMethodTestBean(); + new MethodInvokingAggregator(bean); + } + + @Test(expected = IllegalArgumentException.class) + public void noPublicMethods() { + NoPublicMethodTestBean bean = new NoPublicMethodTestBean(); + new MethodInvokingAggregator(bean); + } + + @Test + public void jdkProxy() { + DirectChannel input = new DirectChannel(); + QueueChannel output = new QueueChannel(); + GreetingService testBean = new GreetingBean(); + ProxyFactory proxyFactory = new ProxyFactory(testBean); + proxyFactory.setProxyTargetClass(false); + testBean = (GreetingService) proxyFactory.getProxy(); + MethodInvokingAggregator aggregator = new MethodInvokingAggregator(testBean); + aggregator.setAutoStartup(false); + aggregator.setOutputChannel(output); + EventDrivenConsumer endpoint = new EventDrivenConsumer(input, aggregator); + endpoint.start(); + Message message = MessageBuilder.withPayload("proxy") + .setCorrelationId("abc") + .build(); + input.send(message); + assertEquals("hello proxy", output.receive(0).getPayload());; + } + + @Test + public void cglibProxy() { + DirectChannel input = new DirectChannel(); + QueueChannel output = new QueueChannel(); + GreetingService testBean = new GreetingBean(); + ProxyFactory proxyFactory = new ProxyFactory(testBean); + proxyFactory.setProxyTargetClass(true); + testBean = (GreetingService) proxyFactory.getProxy(); + MethodInvokingAggregator aggregator = new MethodInvokingAggregator(testBean); + aggregator.setAutoStartup(false); + aggregator.setOutputChannel(output); + EventDrivenConsumer endpoint = new EventDrivenConsumer(input, aggregator); + endpoint.start(); + Message message = MessageBuilder.withPayload("proxy") + .setCorrelationId("abc") + .build(); + input.send(message); + assertEquals("hello proxy", output.receive(0).getPayload());; + } + + + private Method getMethod(MethodInvokingAggregator aggregator) { + Object invoker = new DirectFieldAccessor(aggregator).getPropertyValue("methodInvoker"); + return (Method) new DirectFieldAccessor(invoker).getPropertyValue("method"); + } + + + private static class SingleAnnotationTestBean { + + @Aggregator + public String method1(List input) { + return input.get(0); + } + + public String method2(List input) { + return input.get(0); + } + } + + + private static class MultipleAnnotationTestBean { + + @Aggregator + public String method1(List input) { + return input.get(0); + } + + @Aggregator + public String method2(List input) { + return input.get(0); + } + } + + + private static class NoAnnotationTestBean { + + public String method1(List input) { + return input.get(0); + } + + String method2(List input) { + return input.get(0); + } + } + + + private static class MultiplePublicMethodTestBean { + + public String upperCase(String s) { + return s.toUpperCase(); + } + + public String lowerCase(String s) { + return s.toLowerCase(); + } + } + + + private static class NoPublicMethodTestBean { + + String lowerCase(String s) { + return s.toLowerCase(); + } + } + + + public interface GreetingService { + + String sayHello(List names); + + } + + + public static class GreetingBean implements GreetingService { + + private String greeting = "hello"; + + public void setGreeting(String greeting) { + this.greeting = greeting; + } + + @Aggregator + public String sayHello(List names) { + return greeting + " " + names.get(0); + } + + } + +} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/util/AnnotationMethodResolverTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/util/AnnotationMethodResolverTests.java deleted file mode 100644 index d8adc3df99..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/util/AnnotationMethodResolverTests.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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.util; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Method; - -import org.junit.Test; - -/** - * @author Mark Fisher - */ -public class AnnotationMethodResolverTests { - - @Test - public void singleAnnotation() { - AnnotationMethodResolver resolver = new AnnotationMethodResolver(TestAnnotation.class); - Method method = resolver.findMethod(SingleAnnotationTestBean.class); - assertNotNull(method); - } - - @Test(expected = IllegalArgumentException.class) - public void multipleAnnotations() { - AnnotationMethodResolver resolver = new AnnotationMethodResolver(TestAnnotation.class); - resolver.findMethod(MultipleAnnotationTestBean.class); - } - - @Test - public void noAnnotations() { - AnnotationMethodResolver resolver = new AnnotationMethodResolver(TestAnnotation.class); - Method method = resolver.findMethod(NoAnnotationTestBean.class); - assertNull(method); - } - - - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.RUNTIME) - private static @interface TestAnnotation { - } - - - private static class SingleAnnotationTestBean { - - @TestAnnotation - public String upperCase(String s) { - return s.toUpperCase(); - } - - public String lowerCase(String s) { - return s.toLowerCase(); - } - } - - - private static class MultipleAnnotationTestBean { - - @TestAnnotation - public String upperCase(String s) { - return s.toUpperCase(); - } - - @TestAnnotation - public String lowerCase(String s) { - return s.toLowerCase(); - } - } - - - private static class NoAnnotationTestBean { - - public String upperCase(String s) { - return s.toUpperCase(); - } - - String lowerCase(String s) { - return s.toLowerCase(); - } - } - -} diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/util/DefaultMethodResolverTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/util/DefaultMethodResolverTests.java deleted file mode 100644 index 1a8093f6da..0000000000 --- a/org.springframework.integration/src/test/java/org/springframework/integration/util/DefaultMethodResolverTests.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Method; - -import org.junit.Test; - -import org.springframework.aop.framework.ProxyFactory; -import org.springframework.integration.annotation.ServiceActivator; -import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.endpoint.EventDrivenConsumer; -import org.springframework.integration.handler.ServiceActivatingHandler; -import org.springframework.integration.message.StringMessage; - -/** - * @author Mark Fisher - */ -public class DefaultMethodResolverTests { - - @Test - public void singleAnnotation() { - DefaultMethodResolver resolver = new DefaultMethodResolver(TestAnnotation.class); - Method method = resolver.findMethod(SingleAnnotationTestBean.class); - assertNotNull(method); - } - - @Test(expected = IllegalArgumentException.class) - public void multipleAnnotations() { - DefaultMethodResolver resolver = new DefaultMethodResolver(TestAnnotation.class); - resolver.findMethod(MultipleAnnotationTestBean.class); - } - - @Test - public void singlePublicMethod() { - DefaultMethodResolver resolver = new DefaultMethodResolver(TestAnnotation.class); - Method method = resolver.findMethod(SinglePublicMethodTestBean.class); - assertNotNull(method); - } - - @Test(expected = IllegalArgumentException.class) - public void multiplePublicMethods() { - DefaultMethodResolver resolver = new DefaultMethodResolver(TestAnnotation.class); - resolver.findMethod(MultiplePublicMethodTestBean.class); - } - - @Test - public void noPublicMethods() { - DefaultMethodResolver resolver = new DefaultMethodResolver(TestAnnotation.class); - Method method = resolver.findMethod(NoPublicMethodTestBean.class); - assertNull(method); - } - - @Test - public void jdkProxy() { - DirectChannel input = new DirectChannel(); - QueueChannel output = new QueueChannel(); - GreetingService testBean = new GreetingBean(); - ProxyFactory proxyFactory = new ProxyFactory(testBean); - proxyFactory.setProxyTargetClass(false); - testBean = (GreetingService) proxyFactory.getProxy(); - ServiceActivatingHandler handler = new ServiceActivatingHandler(testBean); - handler.setOutputChannel(output); - EventDrivenConsumer endpoint = new EventDrivenConsumer(input, handler); - endpoint.start(); - input.send(new StringMessage("proxy")); - assertEquals("hello proxy", output.receive(0).getPayload());; - } - - @Test - public void cglibProxy() { - DirectChannel input = new DirectChannel(); - QueueChannel output = new QueueChannel(); - GreetingService testBean = new GreetingBean(); - ProxyFactory proxyFactory = new ProxyFactory(testBean); - proxyFactory.setProxyTargetClass(true); - testBean = (GreetingService) proxyFactory.getProxy(); - ServiceActivatingHandler handler = new ServiceActivatingHandler(testBean); - handler.setOutputChannel(output); - EventDrivenConsumer endpoint = new EventDrivenConsumer(input, handler); - endpoint.start(); - input.send(new StringMessage("proxy")); - assertEquals("hello proxy", output.receive(0).getPayload());; - } - - - @Target(ElementType.METHOD) - @Retention(RetentionPolicy.RUNTIME) - private static @interface TestAnnotation { - } - - - private static class SingleAnnotationTestBean { - - @TestAnnotation - public String upperCase(String s) { - return s.toUpperCase(); - } - - public String lowerCase(String s) { - return s.toLowerCase(); - } - } - - - private static class MultipleAnnotationTestBean { - - @TestAnnotation - public String upperCase(String s) { - return s.toUpperCase(); - } - - @TestAnnotation - public String lowerCase(String s) { - return s.toLowerCase(); - } - } - - - private static class SinglePublicMethodTestBean { - - public String upperCase(String s) { - return s.toUpperCase(); - } - - String lowerCase(String s) { - return s.toLowerCase(); - } - } - - - private static class MultiplePublicMethodTestBean { - - public String upperCase(String s) { - return s.toUpperCase(); - } - - public String lowerCase(String s) { - return s.toLowerCase(); - } - } - - - private static class NoPublicMethodTestBean { - - String lowerCase(String s) { - return s.toLowerCase(); - } - } - - - public interface GreetingService { - - String sayHello(String s); - - } - - - public static class GreetingBean implements GreetingService { - - private String greeting = "hello"; - - public void setGreeting(String greeting) { - this.greeting = greeting; - } - - @ServiceActivator - public String sayHello(String name) { - return greeting + " " + name; - } - - } - -}