Quartz Task Scheduler 0 0 17 * *?

Source: Internet
Author: User
Tags aop xmlns

It programmer development Essentials-all kinds of resources download list, history of the most IT resources, personal collection summary.


Project directory Structure

Spring + Quartz jar Package

Applicationcontext.xml (Beans.xml)[HTML] View Plain Copy <? 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:context = "/http/ Www.springframework.org/schema/context "          xmlns:aop = " HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP "           xsi: schemalocation =  "http://www.springframework.org/schema/beans                  http://www.springframework.org/schema/beans/ spring-beans-2.5.xsd                  Http://www.springframework.org/schema/context                   http://www.springframework.org/schema/context/spring-context-2.5.xsd                  http://www.springframework.org/schema/aop                  http://www.springframework.org/ Schema/aop/spring-aop-2.5.xsd " >                   < context:annotation-config />            < context:component-scan base-package =  "com"  />           < aop:aspectj-autoproxy />                   <!--  Work classes to invoke  -->     &nBsp     < bean id =  "Quartzjob"  class =  " Com.kay.quartz.QuartzJob " ></ bean >      <!--  Methods for defining calling objects and calling objects  -->           < bean id =   "Jobtask"  class =  " Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean " >              <!--  called classes  -->               < property name =  "TargetObject"   >                   <  ref bean =  "Quartzjob"  />                </ property >               <!--  Calling methods in classes  -->                < property name =  "Targetmethod"  >                    <  value > work </ value >                </ property >            </ bean >                     <!--  Define trigger time  -->            < bean id =  "Dotime"  class =  " Org.springframework.scheduling.quartz.CronTriggerBean " >               < property name =  "Jobdetail"  >                    < ref bean =  "Jobtask"  />               </ property >               <!-- cron  Expressions  -->                < property name =  "Cronexpression " >                    < value > 0 0 17 * * ? </ value >                </ property >            </ bean >       <!--&NBSP; general Management class   If you  lazy-init= ' false '   then the container starts executing the scheduler  -->            < bean id =  "Startquertz"  lazy-init =  "false"   autowire =  "No"  class =  "Org.springframework.scheduling.quartz.SchedulerFactoryBean"  >              < property name  =  "triggers"  >                    < list >                        < ref bean =  " Dotime " />                    </ list >                </ property >           </ bean >                </ beans >   



Task Scheduling class [Java] View plain copy package com.kay.quartz;               import java.io.file;       import java.io.filefilter;        import java.io.fileinputstream;       import java.io.fileoutputstream;        import java.util.date;               /**       * quartz  Task Scheduler  ,  every afternoon  17:00,  Automatically  e:/  under  jpg  images  ,  copy to  e:/aa/         *        *  seconds      minutes           Month Zhongtian      month       Week Zhongtian     [  year  ]       *     &NBSP;&NBSP;*&NBSP;0&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;0&NBSP;&NBSP;&NBsp;  17    *        *       ?       *       *  @author  leiwei  2011 - 11 - 29       *       *        */       public class quartzjob {                    public void work ()  throws Exception {              int  b = 0;                        // Make sure the directory exists                 file dir = new file (   "e:/" &NBSP;);                        if  (!dir.exists ()) {                    throw new exception (  "directory not configured"  );                }                       // Use  filefilter to get only jpg files                      FileFilter filter = new  Fileextensionfilefilter (  ". jpg"  );                 file[] files = dir.listfiles (filter);                        // return since there  were no files               if   (files == null | |  files. length <= 0)  {                        system. out .println (  " no xml files found in  " + dir);                         return ;                              }                 &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;//&NBSP;THE&NBSP;NUMBER&NBsp;of jpg files                      int size = files. length ;                           //  Iterate through the files found                       for  ( int i =  0; i < size; i++)  {                         file file = files [i];                                 // Log something  Interesting about each file.                          file afile = file.getabsolutefile ();                                fileinputstream ino = new fileinputstream (AFile) ;                   Fileoutputstream fos = new fileoutputstream (  "e:/aa/"  +file.getname ());                            while  ((B=ino.read ()) >-1) {                        fos.write (b);        &NBSP;&NBSP;&NBSP;&Nbsp;        }                  }                          }      }       //  internal classes, filtering files        class fileextensionfilefilter  implementsfilefilter{                   private   string extension ;                   public fileextensionfilefilter (string extension)  {               this

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.