INT-1715 fixed poller schema definition to allow 'ref' attribute on inner-pollers definitions used in non-core schemas
This commit is contained in:
2
buildSrc
2
buildSrc
Submodule buildSrc updated: d005eb83bf...55c3e5065f
@@ -197,7 +197,11 @@ consumer.setTransactionManager(txManager);</programlisting>
|
||||
output-channel="output">
|
||||
<poller ref="weekdayPoller"/>
|
||||
</transformer>]]></programlisting>
|
||||
In fact, to simplify the configuration, you can define a global default poller. A single top-level poller within
|
||||
<note>
|
||||
The "ref" attribute is only allowed on the inner-poller definitions. Defining his attribute on the top-level
|
||||
poller will result in configuration exception thrown during initialization of Application Context
|
||||
</note>
|
||||
In fact, to simplify the configuration even further, you can define a global default poller. A single top-level poller within
|
||||
an ApplicationContext may have the <code>default</code> attribute with a value of "true". In that case, any
|
||||
endpoint with a PollableChannel for its input-channel that is defined within the same ApplicationContext and has
|
||||
no explicitly configured 'poller' sub-element will use that default.
|
||||
|
||||
@@ -86,7 +86,7 @@ public class PollerParser extends AbstractBeanDefinitionParser {
|
||||
IntegrationNamespaceUtils.BASE_PACKAGE + ".scheduling.PollerMetadata");
|
||||
if (element.hasAttribute("ref")) {
|
||||
parserContext.getReaderContext().error(
|
||||
"the 'ref' attribute must not be present on a 'poller' element submitted to the parser", element);
|
||||
"the 'ref' attribute must not be present on the top-level 'poller' element", element);
|
||||
}
|
||||
configureTrigger(element, metadataBuilder, parserContext);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(metadataBuilder, element, "max-messages-per-poll");
|
||||
|
||||
@@ -673,12 +673,12 @@
|
||||
<xsd:sequence>
|
||||
<xsd:choice>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element ref="beans:bean" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref="beans:bean" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:sequence>
|
||||
</xsd:choice>
|
||||
<xsd:element name="header" type="headerSubElementType" minOccurs="0" maxOccurs="unbounded" />
|
||||
@@ -833,7 +833,7 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
|
||||
<xsd:complexType name="channelAdapterType">
|
||||
<xsd:all>
|
||||
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element ref="beans:bean" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attributeGroup ref="channelAdapterAttributes" />
|
||||
@@ -964,7 +964,7 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
|
||||
<xsd:complexType name="delayer-type">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="default-delay" type="xsd:string" use="required">
|
||||
<xsd:annotation>
|
||||
@@ -1084,7 +1084,7 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
<xsd:element name="header-value-router" type="header-value-router-type" />
|
||||
<xsd:element name="delayer" type="delayer-type" />
|
||||
<xsd:element name="gateway" type="innerGatewayType" />
|
||||
<xsd:element name="poller" type="innerPollerType" />
|
||||
<xsd:element name="poller" type="basePollerType" />
|
||||
<xsd:element name="payload-serializing-transformer" type="payload-serializing-transformer-type" />
|
||||
<xsd:element name="payload-deserializing-transformer" type="payload-deserializing-transformer-type" />
|
||||
<xsd:element name="object-to-string-transformer" type="specialized-transformer-type" />
|
||||
@@ -1114,14 +1114,6 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:complexType name="innerPollerType">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="basePollerType">
|
||||
<xsd:attribute name="ref" type="xsd:string" />
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="basePollerType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
@@ -1181,6 +1173,16 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
<xsd:documentation>Fixed delay trigger (in milliseconds).</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="ref" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Allows this poller to reference another instance of top-level poller.
|
||||
[IMPORTANT] - This attribute is only allowed on inner poller definitions.
|
||||
Defining this attribute on the top-level poller definition will result in the configuration
|
||||
exception.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="fixed-rate" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>Fixed rate trigger (in milliseconds).</xsd:documentation>
|
||||
@@ -1417,7 +1419,7 @@ endpoint itself is a Polling Consumer for a channel with a queue.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" >
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" >
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Allows you to configure Message Poller if this endpoint is a Polling Consumer
|
||||
@@ -2082,7 +2084,7 @@ Name of the header whose value will be used to route messages
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="channelNameResolvingRouterType">
|
||||
<xsd:choice minOccurs="0" maxOccurs="2">
|
||||
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="expression" type="innerExpressionType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:choice>
|
||||
@@ -2603,7 +2605,7 @@ Name of the header whose value will be used to route messages
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="handlerEndpointType">
|
||||
<xsd:choice minOccurs="0" maxOccurs="2">
|
||||
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="expression" type="innerExpressionType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:choice>
|
||||
@@ -2644,7 +2646,7 @@ Name of the header whose value will be used to route messages
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="handlerEndpointType">
|
||||
<xsd:choice minOccurs="0" maxOccurs="2">
|
||||
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:choice>
|
||||
</xsd:extension>
|
||||
@@ -2814,7 +2816,7 @@ The list of component name patterns you want to track (e.g., tracked-components
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:all minOccurs="0" maxOccurs="1">
|
||||
<xsd:element name="poller" type="innerPollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="poller" type="basePollerType" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attributeGroup ref="inputOutputChannelGroup" />
|
||||
</xsd:complexType>
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.scheduling.support.PeriodicTrigger;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
*/
|
||||
public class PollerParserTests {
|
||||
|
||||
@@ -111,4 +112,10 @@ public class PollerParserTests {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"cronTriggerWithTimeUnit-fail.xml", PollerParserTests.class);
|
||||
}
|
||||
|
||||
@Test(expected=BeanDefinitionParsingException.class)
|
||||
public void topLevelPollerWithRef() {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"defaultPollerWithRef.xml", PollerParserTests.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-2.0.xsd">
|
||||
|
||||
<poller id="defaultPollerWithId" default="true" fixed-rate="5000"/>
|
||||
|
||||
<poller id="defaultPollerWithRef" ref="defaultPollerWithId"/>
|
||||
|
||||
</beans:beans>
|
||||
@@ -49,7 +49,7 @@
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:all minOccurs="0" maxOccurs="1">
|
||||
<xsd:element name="poller" type="integration:innerPollerType" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1" />
|
||||
</xsd:all>
|
||||
<xsd:attributeGroup ref="integration:inputOutputChannelGroup" />
|
||||
</xsd:complexType>
|
||||
|
||||
Reference in New Issue
Block a user