Refactored "channel-factory" from sub-element to attribute of the <message-bus/> element.
This commit is contained in:
@@ -42,8 +42,6 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class MessageBusParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
private static final String REFERENCE_ATTRIBUTE = "ref";
|
||||
|
||||
public static final String MESSAGE_BUS_BEAN_NAME = "internal.MessageBus";
|
||||
|
||||
public static final String MESSAGE_BUS_AWARE_POST_PROCESSOR_BEAN_NAME = "internal.MessageBusAwareBeanPostProcessor";
|
||||
@@ -55,10 +53,9 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser {
|
||||
private static final String DEFAULT_CONCURRENCY_ELEMENT = "default-concurrency";
|
||||
|
||||
private static final String DEFAULT_CONCURRENCY_PROPERTY = "defaultConcurrencyPolicy";
|
||||
|
||||
private static final String CHANNEL_FACTORY_ELEMENT = "channel-factory";
|
||||
|
||||
private static final String CHANNEL_FACTORY_PROPERTY = "channelFactory";
|
||||
|
||||
private static final String CHANNEL_FACTORY_ATTRIBUTE = "channel-factory";
|
||||
|
||||
|
||||
@Override
|
||||
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext)
|
||||
@@ -77,7 +74,9 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected boolean isEligibleAttribute(String attributeName) {
|
||||
return !ERROR_CHANNEL_ATTRIBUTE.equals(attributeName) && super.isEligibleAttribute(attributeName);
|
||||
return !ERROR_CHANNEL_ATTRIBUTE.equals(attributeName) &&
|
||||
!CHANNEL_FACTORY_ATTRIBUTE.equals(attributeName) &&
|
||||
super.isEligibleAttribute(attributeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,10 +86,15 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser {
|
||||
beanDefinition.addPropertyReference(Conventions.attributeNameToPropertyName(
|
||||
ERROR_CHANNEL_ATTRIBUTE), errorChannelRef);
|
||||
}
|
||||
this.processAdditionalChildElements(beanDefinition, element);
|
||||
String channelFactoryRef = element.getAttribute(CHANNEL_FACTORY_ATTRIBUTE);
|
||||
if (StringUtils.hasText(channelFactoryRef)) {
|
||||
beanDefinition.addPropertyReference(Conventions.attributeNameToPropertyName(
|
||||
CHANNEL_FACTORY_ATTRIBUTE), channelFactoryRef);
|
||||
}
|
||||
this.processChildElements(beanDefinition, element);
|
||||
}
|
||||
|
||||
private void processAdditionalChildElements(BeanDefinitionBuilder beanDefinition, Element element) {
|
||||
private void processChildElements(BeanDefinitionBuilder beanDefinition, Element element) {
|
||||
NodeList childNodes = element.getChildNodes();
|
||||
for (int i = 0; i < childNodes.getLength(); i++) {
|
||||
Node child = childNodes.item(i);
|
||||
@@ -100,10 +104,6 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
</xsd:annotation>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="default-concurrency" type="concurrencyType" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="channel-factory" type="channelFactoryType" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="auto-startup" type="xsd:boolean"/>
|
||||
<xsd:attribute name="auto-create-channels" type="xsd:boolean"/>
|
||||
<xsd:attribute name="channel-factory" type="xsd:string"/>
|
||||
<xsd:attribute name="error-channel" type="xsd:string"/>
|
||||
<xsd:attribute name="dispatcher-pool-size" type="xsd:int"/>
|
||||
</xsd:complexType>
|
||||
@@ -44,7 +44,7 @@
|
||||
</xsd:annotation>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
||||
<xsd:element name="channel" type="channelType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
@@ -266,15 +266,6 @@
|
||||
<xsd:attribute name="should-fail-on-rejection-limit" type="xsd:boolean"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:complexType name="channelFactoryType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines a channel factory.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="ref" type="xsd:string" use="optional"/>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="concurrencyType">
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -7,14 +7,12 @@
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd">
|
||||
|
||||
<message-bus channel-factory="synchronousChannelFactory"/>
|
||||
|
||||
<message-bus>
|
||||
<channel-factory ref="synchronousChannelFactory"/>
|
||||
</message-bus>
|
||||
|
||||
<beans:bean id="synchronousChannelFactory" class="org.springframework.integration.channel.factory.SynchronousChannelFactory"/>
|
||||
|
||||
<channel id="defaultTypeChannel"/>
|
||||
|
||||
<queue-channel id="specifiedTypeChannel"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
Reference in New Issue
Block a user