<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.

    統(tǒng)計(jì)

    留言簿(10)

    BlogJava

    Blogs

    DIV+CSS

    JQuery相關(guān)

    友情鏈接

    常去的地方

    數(shù)據(jù)供應(yīng)

    閱讀排行榜

    評論排行榜

    spring框架使用任務(wù)調(diào)度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"
    >
        
    <!-- 任務(wù)調(diào)度對象 -->
        
    <bean id="mainJob"
            class
    ="org.springframework.scheduling.quartz.JobDetailBean">
            
    <!-- 運(yùn)行的類 -->
            
    <property name="jobClass">
                
    <value>jobs.MainJob</value>
            
    </property>
            
    <!-- 需要用到的對象 -->
            
    <property name="jobDataAsMap">
                
    <map>
                    
    <entry key="data">
                        
    <value>data</value>
                    
    </entry>
                
    </map>
            
    </property>
        
    </bean>

        
    <!-- 簡單的觸發(fā)器 -->
        
    <bean id="mainTrigger"
            class
    ="org.springframework.scheduling.quartz.SimpleTriggerBean">
            
    <property name="jobDetail">
                
    <!-- 上面創(chuàng)建的任務(wù)調(diào)度對象 -->
                
    <ref bean="mainJob" />
            
    </property>
            
    <!-- 啟動60秒后執(zhí)行任務(wù)調(diào)度的excute方法 -->
            
    <property name="startDelay">
                
    <value>6000</value>
            
    </property>
            
    <!-- 運(yùn)行次數(shù) -->
            
    <property name="repeatCount">
                
    <value>0</value>
            
    </property>
            
    <!-- 隔一個小時運(yùn)行一次(貌似多余,不寫會報(bào)錯) -->
            
    <property name="repeatInterval">
                
    <value>3600000</value>
            
    </property>
        
    </bean>
        
            
        
        
    <!-- 任務(wù)調(diào)度工廠類 -->
        
    <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>
            
    <!-- 觸發(fā)器,可以放一大堆觸發(fā)器 -->
            
    <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 閱讀(2429) 評論(0)  編輯  收藏 所屬分類: J2EE

    主站蜘蛛池模板: 亚洲婷婷综合色高清在线| 国产成人免费a在线资源| 久久一区二区三区免费播放| xxxxx做受大片在线观看免费| 特黄特色大片免费| 国产精品成人亚洲| 国产精品亚洲精品爽爽| 亚洲av永久中文无码精品 | 成人免费视频77777| 在线看免费观看AV深夜影院| 免费在线观看视频网站| 免费AA片少妇人AA片直播| 国产日本一线在线观看免费| 国产大片91精品免费观看不卡| 最近免费2019中文字幕大全| 久视频精品免费观看99| 最近中文字幕无吗高清免费视频| 免费无码一区二区三区蜜桃大| 国产伦精品一区二区三区免费迷| 亚洲精品国产精品乱码不卡| 久久精品夜色噜噜亚洲A∨| 亚洲国产美女精品久久久久∴| 亚洲AV无码国产精品麻豆天美 | 亚洲精品一级无码中文字幕| 亚洲色图综合在线| 精品亚洲永久免费精品| 337p日本欧洲亚洲大胆艺术| 99热亚洲色精品国产88| 美女露隐私全部免费直播| 国产97视频人人做人人爱免费| 未满十八18禁止免费无码网站| 免费黄色网址网站| 日本黄页网站免费| 黑人大战亚洲人精品一区| 亚洲日韩图片专区第1页| 亚洲人成电影在线观看青青| 亚洲AV永久无码精品网站在线观看| 美女羞羞视频免费网站| 东方aⅴ免费观看久久av| 亚洲免费视频网址| 国产精品公开免费视频|