• Spring触发器配置Quartz


    参考文献:http://blog.csdn.net/liaq325/article/details/8269439

    http://sundoctor.iteye.com/blog/441951

    业务类

     public class OpenVirtualService {
                public void open(){ //虚机开通
                   //业务逻辑
                }
          }
    
    第一步,在Spring配置文件中增加本业务类
    
          <bean id="openVirtualService" class="com.stone.product.virtual.service.OpenVirtualService"/>
    
          第二步,定义任务。在Spring配置文件中配置代理类MethodInvokingJobDetailFactoryBean,定义任务的详细信息。
    
          <bean id="openVirtualTask" class= "org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
             <property name="targetObject" ref = "openVirtualService" />
             <property name="targetMethod" value ="open" />
             <property name="concurrent" value =" false " />
          </bean>
    
          这个配置告诉Spring,我们的任务是执行id为businessReport的bean中的perform函数。其中参数concurrent告诉Spring,不要并发运行
    
    这个任务。
    
          第三步,配置一个触发器。在Spring配置文件中配置触发器类CronTriggerBean 。
    
          <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
              <property name="jobDetail" ref="openVirtualTask" />
             <property name="cronExpression" value="0 0 1 1 * ?" />
          </bean>
    
     第四步,配置一个调度器。在Spring配置文件中配置调度器类SchedulerFactoryBean。
    
         <bean class= "org.springframework.scheduling.quartz.SchedulerFactoryBean">
             <property name="triggers">
                <list>
                   <ref bean="cronTrigger" />
                </list>
             </property>
         </bean>
    
         该调度器用于管理触发器。只有在调度器中列表出现的触发器才被Quartz系统调度执行。至此,所有的配置已完成,任务已能正常跑了。
    
  • 相关阅读:
    将cvs迁移到svn
    wincvs,cvs,svn
    Open Source Camp 北京 2008技术交流盛会 感悟
    21,22,23,24日外出纪要
    10.31,11.1外出纪要
    虚拟经济区一行有感
    29,30号活动预告
    ror 2.1.2migration
    netbeans 6.5 release
    [转载]ruby on rails 每周精选二
  • 原文地址:https://www.cnblogs.com/james-roger/p/5805688.html
Copyright © 2020-2023  润新知