From d9263ea92ae3b8e4bd9c5859f91a750eb9abf6ef Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 4 Jan 2011 13:12:49 -0500 Subject: [PATCH] INT-1715 fixed poller schema definition to allow 'ref' attribute on inner-pollers definitions used in non-core schemas --- buildSrc | 2 +- docs/src/reference/docbook/endpoint.xml | 6 ++- .../integration/config/xml/PollerParser.java | 2 +- .../config/xml/spring-integration-2.0.xsd | 38 ++++++++++--------- .../config/xml/PollerParserTests.java | 7 ++++ .../config/xml/defaultPollerWithRef.xml | 14 +++++++ .../config/spring-integration-groovy-2.0.xsd | 2 +- 7 files changed, 49 insertions(+), 22 deletions(-) create mode 100644 spring-integration-core/src/test/java/org/springframework/integration/config/xml/defaultPollerWithRef.xml diff --git a/buildSrc b/buildSrc index d005eb83bf..55c3e5065f 160000 --- a/buildSrc +++ b/buildSrc @@ -1 +1 @@ -Subproject commit d005eb83bfbfb7b12c3cd5262ae331433b538b03 +Subproject commit 55c3e5065f378eaaeae5739ecf078c1f5815845d diff --git a/docs/src/reference/docbook/endpoint.xml b/docs/src/reference/docbook/endpoint.xml index 72cf8b9c96..fb4bf29dcc 100644 --- a/docs/src/reference/docbook/endpoint.xml +++ b/docs/src/reference/docbook/endpoint.xml @@ -197,7 +197,11 @@ consumer.setTransactionManager(txManager); output-channel="output"> ]]> - In fact, to simplify the configuration, you can define a global default poller. A single top-level poller within + + 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 + + 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 default 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. diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PollerParser.java b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PollerParser.java index ed36fdcebb..615d8962e6 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PollerParser.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PollerParser.java @@ -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"); diff --git a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd index 5d14e6fc90..5a53fa076e 100644 --- a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd +++ b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd @@ -673,12 +673,12 @@ - + - + @@ -833,7 +833,7 @@ endpoint itself is a Polling Consumer for a channel with a queue. - + @@ -964,7 +964,7 @@ endpoint itself is a Polling Consumer for a channel with a queue. - + @@ -1084,7 +1084,7 @@ endpoint itself is a Polling Consumer for a channel with a queue. - + @@ -1114,14 +1114,6 @@ endpoint itself is a Polling Consumer for a channel with a queue. - - - - - - - - @@ -1181,6 +1173,16 @@ endpoint itself is a Polling Consumer for a channel with a queue. Fixed delay trigger (in milliseconds). + + + + 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. + + + Fixed rate trigger (in milliseconds). @@ -1417,7 +1419,7 @@ endpoint itself is a Polling Consumer for a channel with a queue. - + 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 - + @@ -2603,7 +2605,7 @@ Name of the header whose value will be used to route messages - + @@ -2644,7 +2646,7 @@ Name of the header whose value will be used to route messages - + @@ -2814,7 +2816,7 @@ The list of component name patterns you want to track (e.g., tracked-components - + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PollerParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PollerParserTests.java index 66343ade6d..8f3babc228 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PollerParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PollerParserTests.java @@ -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); + } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/defaultPollerWithRef.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/defaultPollerWithRef.xml new file mode 100644 index 0000000000..b19492d2a8 --- /dev/null +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/defaultPollerWithRef.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/spring-integration-groovy/src/main/resources/org/springframework/integration/groovy/config/spring-integration-groovy-2.0.xsd b/spring-integration-groovy/src/main/resources/org/springframework/integration/groovy/config/spring-integration-groovy-2.0.xsd index 0f6103ecb8..33365f30fa 100644 --- a/spring-integration-groovy/src/main/resources/org/springframework/integration/groovy/config/spring-integration-groovy-2.0.xsd +++ b/spring-integration-groovy/src/main/resources/org/springframework/integration/groovy/config/spring-integration-groovy-2.0.xsd @@ -49,7 +49,7 @@ - +