This commit is contained in:
Mark Fisher
2009-02-12 19:51:11 +00:00
parent 04e784d033
commit eaad9e1d81
5 changed files with 108 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 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.
@@ -40,7 +40,7 @@ import org.springframework.util.Assert;
*/
public class ConsumerEndpointFactoryBean implements FactoryBean, BeanFactoryAware, BeanNameAware, InitializingBean, ApplicationListener {
private final MessageHandler handler;
private volatile MessageHandler handler;
private volatile String beanName;
@@ -58,10 +58,15 @@ public class ConsumerEndpointFactoryBean implements FactoryBean, BeanFactoryAwar
private final Object initializationMonitor = new Object();
private final Object handlerMonitor = new Object();
public ConsumerEndpointFactoryBean(MessageHandler handler) {
public void setHandler(MessageHandler handler) {
Assert.notNull(handler, "handler must not be null");
this.handler = handler;
synchronized (this.handlerMonitor) {
Assert.isNull(this.handler, "handler cannot be overridden");
this.handler = handler;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 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.
@@ -73,7 +73,7 @@ public abstract class AbstractConsumerEndpointParser extends AbstractBeanDefinit
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
IntegrationNamespaceUtils.BASE_PACKAGE + ".config.ConsumerEndpointFactoryBean");
String handlerBeanName = BeanDefinitionReaderUtils.registerWithGeneratedName(handlerBeanDefinition, parserContext.getRegistry());
builder.addConstructorArgReference(handlerBeanName);
builder.addPropertyReference("handler", handlerBeanName);
String inputChannelName = element.getAttribute(inputChannelAttributeName);
if (!parserContext.getRegistry().containsBeanDefinition(inputChannelName)) {
BeanDefinitionBuilder channelDef = BeanDefinitionBuilder.genericBeanDefinition(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 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.
@@ -37,7 +37,7 @@ public abstract class AbstractOutboundChannelAdapterParser extends AbstractChann
Element pollerElement = DomUtils.getChildElementByTagName(element, "poller");
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
IntegrationNamespaceUtils.BASE_PACKAGE + ".config.ConsumerEndpointFactoryBean");
builder.addConstructorArgReference(this.parseAndRegisterConsumer(element, parserContext));
builder.addPropertyReference("handler", this.parseAndRegisterConsumer(element, parserContext));
if (pollerElement != null) {
if (!StringUtils.hasText(channelName)) {
parserContext.getReaderContext().error(