import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;
import static org.quartz.CronScheduleBuilder.*;
import org.apache.log4j.Logger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.Trigger;
import com.htt.speed.util.CommonUtils;
public class HttSpeedUploadMain {
private static Logger logger = Logger.getLogger(HttSpeedUploadMain.class);
public static void main(String[] args) {
try {
logger.info("上传主程序运行......");
String cronExpression = CommonUtils.getCornExpression();
//1.get Scheduler instance
SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
Scheduler sched = schedFact.getScheduler();
//2.define the job and tie it to our HelloJob class
JobDetail job = newJob(HttSpeedUploadJob.class).withIdentity(
"HttSpeedUploadJob", "HttSpeedUploadJobGroup").build();
//3.Trigger the job to run now
Trigger trigger = newTrigger()
.withIdentity("HttSpeedUploadJobTrigger", "HttSpeedUploadJobTriggerGroup")
.startNow()
.withSchedule(cronSchedule(cronExpression))
.forJob(job)
.build();
//4.Tell quartz to schedule the job using our trigger
sched.scheduleJob(job, trigger);
//5.start the sched
sched.start();
logger.info("上传调度程序运行......");
} catch (Exception e) {
e.printStackTrace();
logger.info("上传主程序运行异常......");
}
}
}