Java Code Examples for org.quartz.CronTrigger#setCronExpression()

The following examples show how to use org.quartz.CronTrigger#setCronExpression() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 스케줄러 Job등록
 * @throws Exception
 * @return void
 */
public void JobRegist() throws Exception {
	Class<?> c = null;
	// 등록할 스케줄 정보 설정
	setSchList();

	for (int j = 0; j < schDTO.length; j++) {
		try {
			c = Class.forName(schDTO[j].getTask_class());

			jobDetail = new JobDetail(schDTO[j].getTask_id(), schDTO[j].getTask_group_id(), c);
			trigger = new CronTrigger(schDTO[j].getTask_id(), schDTO[j].getTask_group_id());

			trigger.setCronExpression(schDTO[j].getTask_expression());
			scheduler.scheduleJob(jobDetail, trigger);
		} catch (Exception e) {
			throw e;
		}
	}
}
 
Example 2
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void JobRegist() throws Exception {
	Class c = null;
	// 등록할 스케줄 정보 설정
	setSchList();

	for (int j = 0; j < schDTO.length; j++) {
		try {
			c = Class.forName(schDTO[j].getTask_class());

			jobDetail = new JobDetail(schDTO[j].getTask_id(), schDTO[j].getTask_group_id(), c);
			trigger = new CronTrigger(schDTO[j].getTask_id(), schDTO[j].getTask_group_id());

			trigger.setCronExpression(schDTO[j].getTask_expression());
			scheduler.scheduleJob(jobDetail, trigger);
		} catch (Exception e) {
			throw e;
		}
	}
}
 
Example 3
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 스케줄러 Job등록
 * @throws Exception
 * @return void
 */
public void JobRegist() throws Exception {
	Class<?> c = null;
	// 등록할 스케줄 정보 설정
	setSchList();

	for (int j = 0; j < schDTO.length; j++) {
		try {
			c = Class.forName(schDTO[j].getTask_class());

			jobDetail = new JobDetail(schDTO[j].getTask_id(), schDTO[j].getTask_group_id(), c);
			trigger = new CronTrigger(schDTO[j].getTask_id(), schDTO[j].getTask_group_id());

			trigger.setCronExpression(schDTO[j].getTask_expression());
			scheduler.scheduleJob(jobDetail, trigger);
		} catch (Exception e) {
			throw e;
		}
	}
}
 
Example 4
Source File: SchedulerMainService.java    From SDA with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void JobRegist() throws Exception {
	Class c = null;
	// 등록할 스케줄 정보 설정
	setSchList();

	for (int j = 0; j < schDTO.length; j++) {
		try {
			c = Class.forName(schDTO[j].getTask_class());

			jobDetail = new JobDetail(schDTO[j].getTask_id(), schDTO[j].getTask_group_id(), c);
			trigger = new CronTrigger(schDTO[j].getTask_id(), schDTO[j].getTask_group_id());

			trigger.setCronExpression(schDTO[j].getTask_expression());
			scheduler.scheduleJob(jobDetail, trigger);
		} catch (Exception e) {
			throw e;
		}
	}
}
 
Example 5
Source File: CmsTaskAct.java    From Lottery with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 开始任务调度
 * @param task 任务
 * @param taskCode 任务名称
 * @throws ParseException
 * @throws SchedulerException
 * @throws ClassNotFoundException
 */
private void startTask(CmsTask task,String taskCode) throws ParseException, SchedulerException, ClassNotFoundException{
	String cronExpress=manager.getCronExpressionFromDB(task.getId());
	System.out.println(cronExpress);
	if(cronExpress.indexOf("null")==-1){
		JobDetail jobDetail = new JobDetail();
		jobDetail.setName(taskCode);
		jobDetail.setGroup(Scheduler.DEFAULT_GROUP);
		jobDetail.setJobClass(getClassByTask(task.getJobClass()));
		//任务需要参数attr属性 
		jobDetail.setJobDataMap(getJobDataMap(task.getAttr()));
		CronTrigger cronTrigger = new CronTrigger("cron_" + taskCode,Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP);
		cronTrigger.setCronExpression(cronExpress);
		scheduler.scheduleJob(jobDetail, cronTrigger); 
	}
}