PollerParser correctly prevents multiple triggers
This commit is contained in:
@@ -120,7 +120,7 @@ public class PollerParser extends AbstractBeanDefinitionParser {
|
||||
}
|
||||
triggerBeanNames.add(triggerAttribute);
|
||||
}
|
||||
else if (StringUtils.hasText(fixedRateAttribute)) {
|
||||
if (StringUtils.hasText(fixedRateAttribute)) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(PERIODIC_TRIGGER_CLASSNAME);
|
||||
builder.addConstructorArgValue(fixedRateAttribute);
|
||||
if (StringUtils.hasText(timeUnit)) {
|
||||
@@ -131,7 +131,7 @@ public class PollerParser extends AbstractBeanDefinitionParser {
|
||||
builder.getBeanDefinition(), parserContext.getRegistry());
|
||||
triggerBeanNames.add(triggerBeanName);
|
||||
}
|
||||
else if (StringUtils.hasText(fixedDelayAttribute)) {
|
||||
if (StringUtils.hasText(fixedDelayAttribute)) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(PERIODIC_TRIGGER_CLASSNAME);
|
||||
builder.addConstructorArgValue(fixedDelayAttribute);
|
||||
if (StringUtils.hasText(timeUnit)) {
|
||||
@@ -142,7 +142,7 @@ public class PollerParser extends AbstractBeanDefinitionParser {
|
||||
builder.getBeanDefinition(), parserContext.getRegistry());
|
||||
triggerBeanNames.add(triggerBeanName);
|
||||
}
|
||||
else if (StringUtils.hasText(cronAttribute)) {
|
||||
if (StringUtils.hasText(cronAttribute)) {
|
||||
if (StringUtils.hasText(timeUnit)) {
|
||||
parserContext.getReaderContext().error("The 'time-unit' attribute cannot be used with a 'cron' trigger.", pollerElement);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -118,4 +118,11 @@ public class PollerParserTests {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"defaultPollerWithRef.xml", PollerParserTests.class);
|
||||
}
|
||||
|
||||
@Test(expected=BeanDefinitionParsingException.class)
|
||||
public void pollerWithCronAndFixedDelay() {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"pollerWithCronAndFixedDelay.xml", PollerParserTests.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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.xsd">
|
||||
|
||||
<poller id="poller" cron="7 * * * * ?" fixed-delay="3000"/>
|
||||
|
||||
</beans:beans>
|
||||
Reference in New Issue
Block a user