Replaced <jms:source/> with <jms:inbound-channel-adapter/>, refactored parser, and adjusted tests.
This commit is contained in:
@@ -19,19 +19,19 @@ package org.springframework.integration.jms.config;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
|
||||
import org.springframework.integration.jms.JmsSource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <jms-source/> element.
|
||||
* Parser for the <inbound-channel-adapter/> element of the 'jms' namespace.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsSourceParser extends AbstractBeanDefinitionParser {
|
||||
public class JmsInboundChannelAdapterParser extends AbstractPollingInboundChannelAdapterParser {
|
||||
|
||||
protected boolean shouldGenerateId() {
|
||||
return false;
|
||||
@@ -42,7 +42,7 @@ public class JmsSourceParser extends AbstractBeanDefinitionParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
protected String parseSource(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(JmsSource.class);
|
||||
String jmsTemplate = element.getAttribute(JmsAdapterParserUtils.JMS_TEMPLATE_ATTRIBUTE);
|
||||
String destination = element.getAttribute(JmsAdapterParserUtils.DESTINATION_ATTRIBUTE);
|
||||
@@ -77,7 +77,7 @@ public class JmsSourceParser extends AbstractBeanDefinitionParser {
|
||||
if (StringUtils.hasText(headerMapper)) {
|
||||
builder.addPropertyReference(JmsAdapterParserUtils.HEADER_MAPPER_PROPERTY, headerMapper);
|
||||
}
|
||||
return builder.getBeanDefinition();
|
||||
return BeanDefinitionReaderUtils.registerWithGeneratedName(builder.getBeanDefinition(), parserContext.getRegistry());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class JmsNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
public void init() {
|
||||
this.registerBeanDefinitionParser("jms-gateway", new JmsGatewayParser());
|
||||
this.registerBeanDefinitionParser("jms-source", new JmsSourceParser());
|
||||
this.registerBeanDefinitionParser("inbound-channel-adapter", new JmsInboundChannelAdapterParser());
|
||||
this.registerBeanDefinitionParser("jms-target", new JmsTargetParser());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,15 +15,17 @@
|
||||
Defines the configuration elements for Spring Integration's JMS adapters.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:element name="jms-source">
|
||||
|
||||
<xsd:element name="inbound-channel-adapter">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines a JMS-based source channel adapter.
|
||||
Defines a JMS-based inbound Channel Adapter.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="jmsInboundAdapterType">
|
||||
<xsd:attribute name="channel" type="xsd:string"/>
|
||||
<xsd:attribute name="header-mapper" type="xsd:string"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
|
||||
Reference in New Issue
Block a user