polishing

This commit is contained in:
Mark Fisher
2008-05-15 13:39:58 +00:00
parent 37b2f0a87d
commit ce37d6b4e7
4 changed files with 23 additions and 34 deletions

View File

@@ -42,11 +42,11 @@ public abstract class AbstractChannelFactory implements ChannelFactory {
}
return channel;
}
/**
* Factory method to be overridden by subclasses. It assumes that subclasses will return
* subclasses of AbstractMessageChannel.
*/
protected abstract AbstractMessageChannel createChannelInternal(DispatcherPolicy dispatcherPolicy);
}
}

View File

@@ -29,11 +29,12 @@ import org.springframework.integration.channel.MessageChannel;
import org.springframework.util.Assert;
/**
* Creates a channel by delegating to the current message bus-configured
* Creates a channel by delegating to the current message bus' configured
* ChannelFactory. Tries to retrieve the {@link ChannelFactory} from the
* single {@link MessageBus} defined in the {@link ApplicationContext}.
* As a {@link FactoryBean}, this class is solely intended to be used within
* an ApplicationContext.
*
* @author Marius Bogoevici
*/
public class DefaultChannelFactoryBean implements ApplicationContextAware, FactoryBean{
@@ -43,15 +44,14 @@ public class DefaultChannelFactoryBean implements ApplicationContextAware, Facto
private volatile List<ChannelInterceptor> interceptors;
private volatile DispatcherPolicy dispatcherPolicy;
private volatile boolean publisherSubscriber;
public DefaultChannelFactoryBean(DispatcherPolicy dispatcherPolicy) {
this.dispatcherPolicy = dispatcherPolicy;
}
@SuppressWarnings("unchecked")
public void setApplicationContext(ApplicationContext applicationContext){
Map map = applicationContext.getBeansOfType(MessageBus.class);
Assert.state(map.size() <= 1, "There is more than one MessageBus in the ApplicationContext");
@@ -59,7 +59,7 @@ public class DefaultChannelFactoryBean implements ApplicationContextAware, Facto
this.channelFactory = new QueueChannelFactory();
}
else {
this.channelFactory = ((MessageBus)map.values().iterator().next()).getChannelFactory();
this.channelFactory = ((MessageBus) map.values().iterator().next()).getChannelFactory();
}
}
@@ -72,7 +72,7 @@ public class DefaultChannelFactoryBean implements ApplicationContextAware, Facto
return channelFactory.getChannel(dispatcherPolicy, interceptors);
}
public Class getObjectType() {
public Class<?> getObjectType() {
return MessageChannel.class;
}

View File

@@ -22,8 +22,8 @@ import org.springframework.integration.channel.RendezvousChannel;
/**
* A {@link ChannelFactory} for creating {@link RendezvousChannel} instances.
*
* @author Marius Bogoevici
*
*/
public class RendezvousChannelFactory extends AbstractChannelFactory {

View File

@@ -16,6 +16,10 @@
package org.springframework.integration.config;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
@@ -28,11 +32,7 @@ import org.springframework.core.Conventions;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.bus.MessageBus;
import org.springframework.integration.bus.MessageBusAwareBeanPostProcessor;
import org.springframework.integration.endpoint.ConcurrencyPolicy;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Parser for the <em>message-bus</em> element of the integration namespace.
@@ -95,30 +95,19 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser {
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
processIfConcurrencyElement(beanDefinition, child);
processIfChannelFactoryElement(beanDefinition, child);
String localName = child.getLocalName();
if (DEFAULT_CONCURRENCY_ELEMENT.equals(localName)) {
beanDefinition.addPropertyValue(DEFAULT_CONCURRENCY_PROPERTY,
IntegrationNamespaceUtils.parseConcurrencyPolicy((Element) child));
}
else if (CHANNEL_FACTORY_ELEMENT.equals(localName)) {
beanDefinition.addPropertyReference(CHANNEL_FACTORY_PROPERTY,
((Element) child).getAttribute(REFERENCE_ATTRIBUTE));
}
}
}
}
private void processIfConcurrencyElement(BeanDefinitionBuilder beanDefinition, Node node) {
String localName = node.getLocalName();
if (DEFAULT_CONCURRENCY_ELEMENT.equals(localName)) {
ConcurrencyPolicy policy = IntegrationNamespaceUtils.parseConcurrencyPolicy((Element) node);
beanDefinition.addPropertyValue(DEFAULT_CONCURRENCY_PROPERTY, policy);
}
}
private void processIfChannelFactoryElement(BeanDefinitionBuilder beanDefinition, Node node) {
String localName = node.getLocalName();
if (CHANNEL_FACTORY_ELEMENT.equals(localName)) {
beanDefinition.addPropertyReference(CHANNEL_FACTORY_PROPERTY, ((Element) node)
.getAttribute(REFERENCE_ATTRIBUTE));
}
}
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
super.doParse(element, parserContext, builder);