Force lazy-init to false when parsing scheduled:task

A <scheduled:task> element declared within a
<beans default-lazy-init="true"> element represents a contradiction in
terms: such a task will never be executed.

For this reason, we now override any inherited lazy-init settings
when parsing <scheduled:task> elements, forcing lazy-init to false
for the underlying ScheduledTaskRegistrar bean.

Thanks to Mike Youngstrom for contributing an initial patch.

Issue: SPR-8498
This commit is contained in:
Chris Beams
2011-07-19 23:00:12 +00:00
parent 576b8fec31
commit 718f025d64
3 changed files with 70 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"
default-lazy-init="true">
<task:scheduled-tasks>
<task:scheduled ref="myTask" method="doWork" fixed-rate="10"/>
</task:scheduled-tasks>
<bean id="myTask" class="org.springframework.scheduling.config.LazyScheduledTasksBeanDefinitionParserTests$Task"/>
</beans>