INT-911 created a separate XSD element for the 'gateway' used inside a chain, to avoid 'default' in the attribute names

This commit is contained in:
Mark Fisher
2009-12-24 15:09:49 +00:00
parent c8683b5ab4
commit a8f3edd52a
4 changed files with 73 additions and 24 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.
@@ -37,6 +37,11 @@ public class GatewayParser extends AbstractSimpleBeanDefinitionParser {
"default-request-channel", "default-reply-channel", "message-mapper"
};
private static String[] innerAttributes = new String[] {
"request-channel", "reply-channel", "request-timeout", "reply-timeout"
};
@Override
protected String getBeanClassName(Element element) {
return IntegrationNamespaceUtils.BASE_PACKAGE + ".gateway.GatewayProxyFactoryBean";
@@ -45,11 +50,28 @@ public class GatewayParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected boolean isEligibleAttribute(String attributeName) {
return !ObjectUtils.containsElement(referenceAttributes, attributeName)
&& !ObjectUtils.containsElement(innerAttributes, attributeName)
&& super.isEligibleAttribute(attributeName);
}
@Override
protected void postProcess(BeanDefinitionBuilder builder, Element element) {
if ("chain".equals(element.getParentNode().getLocalName())) {
this.postProcessInnerGateway(builder, element);
}
else {
this.postProcessGateway(builder, element);
}
}
private void postProcessInnerGateway(BeanDefinitionBuilder builder, Element element) {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "request-channel", "defaultRequestChannel");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel", "defaultReplyChannel");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "request-timeout", "defaultRequestTimeout");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout", "defaultReplyTimeout");
}
private void postProcessGateway(BeanDefinitionBuilder builder, Element element) {
for (String attributeName : referenceAttributes) {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, attributeName);
}

View File

@@ -350,6 +350,36 @@
</xsd:complexType>
</xsd:element>
<xsd:complexType name="innerGatewayType">
<xsd:annotation>
<xsd:documentation>
Defines a Messaging Gateway to be used within a chain.
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="request-channel" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type
type="org.springframework.integration.core.MessageChannel" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="reply-channel" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type
type="org.springframework.integration.core.MessageChannel" />
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="request-timeout" type="xsd:string" />
<xsd:attribute name="reply-timeout" type="xsd:string" />
</xsd:complexType>
<xsd:element name="inbound-channel-adapter" type="methodInvokingChannelAdapterType">
<xsd:annotation>
<xsd:documentation>
@@ -706,7 +736,7 @@
<xsd:element ref="router" />
<xsd:element ref="delayer" />
<xsd:element ref="chain" />
<xsd:element ref="gateway" />
<xsd:element name="gateway" type="innerGatewayType" />
<xsd:element name="poller" type="innerPollerType" />
</xsd:choice>
</xsd:extension>