Added some constraints for poller parsing.
This commit is contained in:
@@ -145,6 +145,10 @@ public abstract class IntegrationNamespaceUtils {
|
||||
public static void configurePollerMetadata(Element pollerElement, BeanDefinitionBuilder targetBuilder, ParserContext parserContext) {
|
||||
String pollerMetadataRef = null;
|
||||
if (pollerElement.hasAttribute("ref")) {
|
||||
Assert.isTrue(pollerElement.getAttributes().getLength() == 1,
|
||||
"a 'poller' element that provides a 'ref' must have no other attributes");
|
||||
Assert.isTrue(pollerElement.getChildNodes().getLength() == 0,
|
||||
"a 'poller' element that provides a 'ref' must have no child elements");
|
||||
pollerMetadataRef = pollerElement.getAttribute("ref");
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -55,6 +55,8 @@ public class PollerParser extends AbstractBeanDefinitionParser {
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder metadataBuilder = BeanDefinitionBuilder.genericBeanDefinition(PollerMetadata.class);
|
||||
Assert.isTrue(!element.hasAttribute("ref"),
|
||||
"the 'ref' attribute must not be present on a 'poller' element submitted to the parser");
|
||||
configureTrigger(element, metadataBuilder, parserContext);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(metadataBuilder, element, "max-messages-per-poll");
|
||||
Element txElement = DomUtils.getChildElementByTagName(element, "transactional");
|
||||
|
||||
@@ -366,7 +366,7 @@
|
||||
Defines an interval-based trigger.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="interval" type="xsd:string"/>
|
||||
<xsd:attribute name="interval" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="initial-delay" type="xsd:string"/>
|
||||
<xsd:attribute name="fixed-rate" type="xsd:string" default="false"/>
|
||||
<xsd:attribute name="time-unit" default="MILLISECONDS">
|
||||
@@ -394,7 +394,7 @@
|
||||
Defines an cron-based trigger.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="expression" type="xsd:string"/>
|
||||
<xsd:attribute name="expression" type="xsd:string" use="required"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user