diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/annotation/ChannelAdapter.java b/org.springframework.integration/src/main/java/org/springframework/integration/annotation/ChannelAdapter.java deleted file mode 100644 index 0c490b16b2..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/annotation/ChannelAdapter.java +++ /dev/null @@ -1,51 +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.annotation; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.stereotype.Component; - -/** - * Indicates that a method is capable of serving as a message channel. - * If the method accepts no arguments but does define a non-void return - * type, an inbound Channel Adapter will be created. If the method does - * accept an argument and has a void return, an outbound Channel Adapter - * will be created. If the method does not conform to either contract, - * an Exception will be thrown. - * - * @author Mark Fisher - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -@Documented -@Component -public @interface ChannelAdapter { - - /** - * The name of the channel being adapted. If the channel - * name is not resolvable, a new channel will be created. - */ - String value(); - -} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/ChannelAdapterAnnotationPostProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/ChannelAdapterAnnotationPostProcessor.java deleted file mode 100644 index 1edd59c59f..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/ChannelAdapterAnnotationPostProcessor.java +++ /dev/null @@ -1,89 +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.config.annotation; - -import java.lang.reflect.Method; - -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.integration.annotation.ChannelAdapter; -import org.springframework.integration.channel.BeanFactoryChannelResolver; -import org.springframework.integration.channel.ChannelResolutionException; -import org.springframework.integration.channel.ChannelResolver; -import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.channel.SubscribableChannel; -import org.springframework.integration.core.MessageChannel; -import org.springframework.integration.endpoint.EventDrivenConsumer; -import org.springframework.integration.handler.MethodInvokingMessageHandler; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -/** - * Post-processor for methods annotated with {@link ChannelAdapter @ChannelAdapter}. - * - * @author Mark Fisher - */ -public class ChannelAdapterAnnotationPostProcessor implements MethodAnnotationPostProcessor { - - private final ConfigurableBeanFactory beanFactory; - - private final ChannelResolver channelResolver; - - - public ChannelAdapterAnnotationPostProcessor(ConfigurableBeanFactory beanFactory) { - Assert.notNull(beanFactory, "BeanFactory must not be null"); - this.beanFactory = beanFactory; - this.channelResolver = new BeanFactoryChannelResolver(this.beanFactory); - } - - - public Object postProcess(Object bean, String beanName, Method method, ChannelAdapter annotation) { - Assert.notNull(this.beanFactory, "BeanFactory must not be null"); - MessageChannel channel = this.resolveOrCreateChannel(annotation.value()); - Assert.isInstanceOf(SubscribableChannel.class, channel, - "The channel for an Annotation-based Channel Adapter must be a SubscribableChannel."); - Assert.isTrue(method.getParameterTypes().length > 0, - "A method annotated with @ChannelAdapter must accept at least one argument."); - Assert.isTrue(!hasReturnValue(method), - "A method annotated with @ChannelAdapter must not have a return value." - + " Consider using a @ServiceActivator if a reply Message is expected."); - MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(bean, method); - EventDrivenConsumer endpoint = new EventDrivenConsumer((SubscribableChannel) channel, handler); - String annotationName = ClassUtils.getShortNameAsProperty(annotation.annotationType()); - String endpointName = beanName + "." + method.getName() + "." + annotationName; - this.beanFactory.registerSingleton(endpointName, endpoint); - endpoint.setBeanFactory(beanFactory); - endpoint.afterPropertiesSet(); - return bean; - } - - private MessageChannel resolveOrCreateChannel(String channelName) { - try { - return this.channelResolver.resolveChannelName(channelName); - } - catch (ChannelResolutionException e) { - DirectChannel directChannel = new DirectChannel(); - directChannel.setBeanName(channelName); - this.beanFactory.registerSingleton(channelName, directChannel); - return directChannel; - } - } - - private boolean hasReturnValue(Method method) { - return !method.getReturnType().equals(void.class); - } - -} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java index f4e5c2c18e..a9fb119b99 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessor.java @@ -39,7 +39,6 @@ import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.integration.annotation.Aggregator; -import org.springframework.integration.annotation.ChannelAdapter; import org.springframework.integration.annotation.Router; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.integration.annotation.Splitter; @@ -78,7 +77,6 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean public void afterPropertiesSet() { Assert.notNull(this.beanFactory, "BeanFactory must not be null"); postProcessors.put(Aggregator.class, new AggregatorAnnotationPostProcessor(this.beanFactory)); - postProcessors.put(ChannelAdapter.class, new ChannelAdapterAnnotationPostProcessor(this.beanFactory)); postProcessors.put(Router.class, new RouterAnnotationPostProcessor(this.beanFactory)); postProcessors.put(ServiceActivator.class, new ServiceActivatorAnnotationPostProcessor(this.beanFactory)); postProcessors.put(Splitter.class, new SplitterAnnotationPostProcessor(this.beanFactory)); @@ -133,9 +131,6 @@ public class MessagingAnnotationPostProcessor implements BeanPostProcessor, Bean } private boolean shouldCreateEndpoint(Annotation annotation) { - if (annotation instanceof ChannelAdapter) { - return true; - } Object inputChannel = AnnotationUtils.getValue(annotation, "inputChannel"); return (inputChannel != null && inputChannel instanceof String && StringUtils.hasText((String) inputChannel));