xml:
<?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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd"
default-lazy-init="true">
<description>racAccountQuartz的定时任务配置</description>
<bean id="racAccountTask" class="com.cacss.itas.rac.schedule.RacAccountQuartzTask"></bean>
<bean id="RacschedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="banKAccountTrigger" />
<ref bean="chartOfAccountTrigger"/>
</list>
</property>
</bean>
<!-- bankAccountTask -->
<bean id="banKAccountTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<ref bean="bankAccountJobDetail" />
</property>
<property name="cronExpression">
<value>0 5 0 * * ?</value>
</property>
</bean>
<!--schedule manage -->
<bean id="bankAccountJobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="concurrent" value="false"/>
<property name="targetObject" ref="racAccountTask"></property>
<property name="targetMethod" value="bankAccountTask"></property>
</bean>
<!-- chartOfAccountTrigger -->
<bean id="chartOfAccountTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<ref bean="chartOfAccountJobDetail" />
</property>
<property name="cronExpression">
<value>0 5 0 * * ?</value>
</property>
</bean>
<!--schedule manage -->
<bean id="chartOfAccountJobDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="concurrent" value="false"/>
<property name="targetObject" ref="racAccountTask"></property>
<property name="targetMethod" value="chartOfAccountTask"></property>
</bean>
</beans>
RacAccountQuartzTask.java
package com.cacss.itas.rac.schedule;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.cacss.itas.rac.service.ext.IRacBankAccountProcessService;
import com.cacss.itas.rac.service.ext.IRacChartOfAccountProcessService;
@Component
public class RacAccountQuartzTask {
private static final Logger logger = Logger.getLogger(RacAccountQuartzTask.class);
@Autowired
IRacBankAccountProcessService iRacBankAccountProcessService;
@Autowired
IRacChartOfAccountProcessService iRacChartOfAccountProcessService;
/**
* update bank account status
*/
public void bankAccountTask() {
try {
iRacBankAccountProcessService.updateAccountStatus();
} catch (Exception e) {
logger.error(e.getMessage());
}
}
/**
* update chart of account status
*/
public void chartOfAccountTask() {
try {
iRacChartOfAccountProcessService.updateAccountStatus();
} catch (Exception e) {
logger.error(e.getMessage());
}
}
}