Files
java-tutorials/spring-scheduling/src/main/resources/springScheduled-config.xml
T

29 lines
1.6 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
>
<context:property-placeholder location="classpath:springScheduled.properties"/>
<!-- Configure the scheduler -->
<task:scheduler id="myScheduler" pool-size="10"/>
<bean id="myscheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler"/>
<!-- Configure the fixedDealy, fixedRate or cron based schduled tasks -->
<bean id="schedulingWithXmlConfig" class="org.baeldung.scheduling.SchedulingWithXmlConfig"/>
<task:scheduled-tasks scheduler="myScheduler">
<task:scheduled ref="schedulingWithXmlConfig" method="scheduleFixedDelayTask"
fixed-delay="${fixedDelay.in.milliseconds}" initial-delay="1000"/>
<task:scheduled ref="schedulingWithXmlConfig" method="scheduleFixedRateTask"
fixed-rate="${fixedRate.in.milliseconds}"/>
<task:scheduled ref="schedulingWithXmlConfig" method="scheduleTaskUsingCronExpression"
cron="${cron.expression}"/>
</task:scheduled-tasks>
</beans>