<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Java Blog for Alex Wan

    Let life be beautiful like summer flowers and death like autumn leaves.

    統計

    留言簿(10)

    BlogJava

    Blogs

    DIV+CSS

    JQuery相關

    友情鏈接

    常去的地方

    數據供應

    閱讀排行榜

    評論排行榜

    spring框架使用任務調度quartz的例子-Job and Trigger 篇

    MainJob.java
     1package jobs;
     2
     3import org.apache.log4j.Logger;
     4import org.quartz.JobExecutionContext;
     5import org.quartz.JobExecutionException;
     6import org.springframework.scheduling.quartz.QuartzJobBean;
     7
     8public class MainJob extends QuartzJobBean {
     9    private  Logger logger = Logger.getLogger(getClass());
    10    @Override
    11    protected void executeInternal(JobExecutionContext context)
    12            throws JobExecutionException {
    13        // TODO Auto-generated method stub
    14        logger.debug("Just say hi.");
    15    }

    16
    17}

    18
    application.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:jee
    ="http://www.springframework.org/schema/jee"
        xsi:schemaLocation
    ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
               http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd"
    >
        
    <!-- 任務調度對象 -->
        
    <bean id="mainJob"
            class
    ="org.springframework.scheduling.quartz.JobDetailBean">
            
    <!-- 運行的類 -->
            
    <property name="jobClass">
                
    <value>jobs.MainJob</value>
            
    </property>
            
    <!-- 需要用到的對象 -->
            
    <property name="jobDataAsMap">
                
    <map>
                    
    <entry key="data">
                        
    <value>data</value>
                    
    </entry>
                
    </map>
            
    </property>
        
    </bean>

        
    <!-- 簡單的觸發器 -->
        
    <bean id="mainTrigger"
            class
    ="org.springframework.scheduling.quartz.SimpleTriggerBean">
            
    <property name="jobDetail">
                
    <!-- 上面創建的任務調度對象 -->
                
    <ref bean="mainJob" />
            
    </property>
            
    <!-- 啟動60秒后執行任務調度的excute方法 -->
            
    <property name="startDelay">
                
    <value>6000</value>
            
    </property>
            
    <!-- 運行次數 -->
            
    <property name="repeatCount">
                
    <value>0</value>
            
    </property>
            
    <!-- 隔一個小時運行一次(貌似多余,不寫會報錯) -->
            
    <property name="repeatInterval">
                
    <value>3600000</value>
            
    </property>
        
    </bean>
        
            
        
        
    <!-- 任務調度工廠類 -->
        
    <bean
            
    class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            
    <!-- 這一部分的配置不用管 -->
            
    <property name="quartzProperties">
                
    <props>
                    
    <prop key="org.quartz.threadPool.class">
                        org.quartz.simpl.SimpleThreadPool
                    
    </prop>
                    
    <prop key="org.quartz.threadPool.threadCount">10</prop>
                    
    <prop key="org.quartz.threadPool.threadPriority">
                        5
                    
    </prop>
                    
    <prop
                        
    key="org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread">
                        true
                    
    </prop>

                
    </props>
            
    </property>
            
    <!-- 觸發器,可以放一大堆觸發器 -->
            
    <property name="triggers">
                
    <list>
                    
    <!-- 在這里加 -->
                     
    <ref bean="mainTrigger"/>
                
    </list>
            
    </property>

        
    </bean>
    </beans>


    Let life be beautiful like summer flowers and death like autumn leaves.

    posted on 2008-06-11 23:21 Alexwan 閱讀(2431) 評論(0)  編輯  收藏 所屬分類: J2EE

    主站蜘蛛池模板: 亚洲av中文无码字幕色不卡| 99久久亚洲综合精品成人网| 亚洲AV无码成人专区| 少妇无码一区二区三区免费| 久久亚洲国产成人影院网站| 一级毛片成人免费看a| 青青草原1769久久免费播放| 中文字幕在线亚洲精品 | 亚洲AV成人精品日韩一区| 国产日韩AV免费无码一区二区三区| 永久在线观看免费视频| 亚洲爆乳精品无码一区二区三区| 国产在线一区二区综合免费视频| 91香蕉成人免费网站| 久久精品国产亚洲αv忘忧草| 最近中文字幕无免费视频| 亚洲精品无码专区久久同性男| 亚洲精品视频专区| 精品久久亚洲一级α| 在线a亚洲v天堂网2018| 亚洲六月丁香六月婷婷蜜芽| 成人最新午夜免费视频| 一级毛片高清免费播放| 亚洲成AV人片在线播放无码| 国产成人精品免费视频大全麻豆| 男人天堂2018亚洲男人天堂| 国产h视频在线观看网站免费| 亚洲色大18成人网站WWW在线播放| 国产乱人免费视频| a级片免费在线观看| 亚洲性猛交XXXX| 91免费国产自产地址入| 国产精品亚洲精品久久精品| 国产精品亚洲片在线| 好男人www免费高清视频在线| 亚洲综合精品一二三区在线| 处破痛哭A√18成年片免费| eeuss免费天堂影院| 亚洲欧洲日产国码一级毛片| 亚洲视频在线免费看| 在线亚洲97se亚洲综合在线|