spring quartz 시작 시간 종료 시간 에 따라 동적 설정 작업

//       
			JobDataMap jobDataMap = new JobDataMap();
			//     spring bean            
			jobDataMap.put("targetObject",
					springContext.getBean("simpleService"));
			//     
			jobDataMap.put("targetMethod", "testMethod2");

			jobDataMap.put("shouldRecover", "true");
			//         
			JobDetail newJob = new JobDetail();
			//     
			newJob.setName("jobDetail3");
			//       
			newJob.setJobDataMap(jobDataMap);
			//   
			newJob.setGroup("DEFAUL");
			//    (               )
			newJob.setJobClass(MethodInvokingJobDetailFactoryBean.MethodInvokingJob.class);
			
			Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
			
			SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd");
	        String str = "2013-10-16 00:00:00";
	        String str2 ="2013-10-18 00:00:00";
	        Date  time = formatDate.parse(str);
	        Date  time2 = formatDate.parse(str2);
		//                        (   )
            SimpleTrigger simpleTrigger = new SimpleTrigger();
            //      
            simpleTrigger.setGroup(Scheduler.DEFAULT_GROUP);
            //     
            simpleTrigger.setName("cronTrigger3");
            //SimpleTrigger.REPEAT_INDEFINITELY     
            //simpleTrigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
            simpleTrigger.setRepeatCount(10);
            //      (  )
            simpleTrigger.setRepeatInterval(10);
            //      
            simpleTrigger.setStartTime(time);
            // 1  
            simpleTrigger.setTimesTriggered(1);
            //      
            simpleTrigger.setEndTime(time2);
            scheduler.scheduleJob(newJob, simpleTrigger);
			

좋은 웹페이지 즐겨찾기