RouterAnnotationPostProcessor now provides the beanFactory reference to the MethodInvokingRouter it creates.

This commit is contained in:
Mark Fisher
2008-10-10 23:54:17 +00:00
parent cb90d39657
commit 045011318e
2 changed files with 3 additions and 1 deletions

View File

@@ -51,7 +51,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
private static final String OUTPUT_CHANNEL_ATTRIBUTE = "outputChannel";
private final GenericBeanFactoryAccessor beanFactoryAccessor;
protected final GenericBeanFactoryAccessor beanFactoryAccessor;
protected final ChannelRegistry channelRegistry;

View File

@@ -22,6 +22,7 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.integration.annotation.Router;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.message.MessageConsumer;
import org.springframework.integration.router.BeanNameChannelMapping;
import org.springframework.integration.router.MethodInvokingRouter;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -41,6 +42,7 @@ public class RouterAnnotationPostProcessor extends AbstractMethodAnnotationPostP
@Override
protected MessageConsumer createConsumer(Object bean, Method method, Router annotation) {
MethodInvokingRouter router = new MethodInvokingRouter(bean, method);
router.setChannelMapping(new BeanNameChannelMapping(this.beanFactoryAccessor.getBeanFactory()));
String defaultOutputChannelName = annotation.defaultOutputChannel();
if (StringUtils.hasText(defaultOutputChannelName)) {
MessageChannel defaultOutputChannel = this.channelRegistry.lookupChannel(defaultOutputChannelName);