论坛首页 入门技术论坛

spring中quartz多任务

浏览 2937 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-03-03  

 刚做项目中的任务调度,高级的方法不会(望大家告诉点高级货色),笨点的方法是:


    <bean id="testTask" class="com.sqmis.task.TestTask">
        <property name="repositoryContentService"
            ref="repositoryContentServiceAopProxy" />
    </bean>
       
    <bean id="methodInvokingJobDetail"
        class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject"><ref bean="testTask"/></property>
        <!--  <property name="targetMethod"><value>hotVisitPrepare</value></property>-->
         <property name="targetMethod"><value>repositoryAbate</value></property>
    </bean>
     <bean id="hotVisitPrepareMethodInvokingJobDetail"
        class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject"><ref bean="testTask"/></property>
         <property name="targetMethod"><value>hotVisitPrepare</value></property>
    </bean>      

    <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="methodInvokingJobDetail"/>
        </property>
        <property name="cronExpression">
            <value>0 0 1 * * ?</value>
        </property>
    </bean>
   
    <bean id="hotVisitPrepareCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail">
            <ref bean="hotVisitPrepareMethodInvokingJobDetail"/>
        </property>
        <property name="cronExpression">
            <value>0 30 1 * * ?</value>
        </property>
    </bean>

    <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref local="cronTrigger"/>
                <ref local="hotVisitPrepareCronTrigger"/>

            </list>
        </property>
    </bean>

   发表时间:2009-05-24  
very good
1 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics