spring quartz 线程调度服务

2014/12/24 14:41
阅读数 37

    <!-- spring 线程调度注册,  注册执行的任务 class 和 被执行的 service -->
    <bean id="deptSyncJob" class="org.springframework.scheduling.quartz.JobDetailBean">
        <property name="jobClass">
           <value>com.openid.rst.server.quartz.DepartmentSyncJob</value>
        </property>
        <property name="jobDataAsMap">
          <map>
           <entry key="someService">
             <ref bean="someService"/>
           </entry>
         </map>
        </property>
    </bean>

 

    <!--

      /** 实现的线程执行类  */

       package com.openid.rst.server.quartz;

       import org.quartz.JobExecutionContext;
       import org.quartz.JobExecutionException;
       import com.openid.rst.service.SecurityService;
       import org.springframework.scheduling.quartz.QuartzJobBean;

 

      public class DepartmentSyncJob extends QuartzJobBean {

 
       public SecurityService getSecurityService() {
          return this.securityService;
       }

 

       public void setSecurityService(SecurityService securityService) {
          this.securityService = securityService;
       }

 

       private SecurityService securityService;
   

       protected void executeInternal(JobExecutionContext context)
           throws JobExecutionException {
        securityService.doDeptSyncFromIddbuser();
       }

   }

       -->
   

  

    <!-- spring 配置线程调用及参数 -->
    <bean id="simpleReportTrigger"                     class="org.springframework.scheduling.quartz.SimpleTriggerBean">
       <property name="jobDetail">
            <ref bean="deptSyncJob"/>
       </property>
      
       <!--
       <property name="startDelay">  
            <value>1800000-nouse </value>
       </property>
      -->
     
       <property name="startDelay">
            <value>12000</value>
       </property>
      
       <property name="repeatInterval">
            <value>86400000</value>
       </property>

    </bean>

 

   

   <!-- 线程执行工厂 -->

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

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部