Added some constraints for poller parsing.

This commit is contained in:
Mark Fisher
2008-11-25 03:05:12 +00:00
parent 3717556f19
commit 23db1c0fe9
3 changed files with 8 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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");

View File

@@ -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>