snaker-quartz/src/main/java/org/snaker/engine/scheduling/quartz/QuartzScheduler.java
public void schedule(JobEntity entity) {
		AssertHelper.notNull(entity);
	    JobDataMap data = new JobDataMap(entity.getArgs());
	    data.put(KEY, entity.getId());
	    data.put(MODEL, entity.getModelName());
	    Class<? extends Job> jobClazz = null;
	    String jobId = "";
	    switch(entity.getJobType()) {
	    case 0:
	    	jobClazz = ExecutorJob.class;
	    	jobId = TYPE_EXECUTOR + entity.getTask().getId();
	    	break;
	    case 1:
	    	jobClazz = ReminderJob.class;
	    	jobId = TYPE_REMINDER + entity.getTask().getId();
	    	break;
	    }
	    if(jobClazz == null) {
	    	log.error("Quartz不支持的JOB类型:{}", entity.getJobType());
	    	return;
	    }
	    
	    JobDetail job = JobBuilder
	    		.newJob(jobClazz)
	    		.usingJobData(data)
	    		.withIdentity(jobId, GROUP)
	    		.build();
	    Trigger trigger = null;
	    TriggerBuilder<Trigger> builder = TriggerBuilder
	    		.newTrigger()
	    		.withIdentity(StringHelper.getPrimaryKey(), GROUP)
	    		.startAt(entity.getStartTime());
	    if(jobClazz == ReminderJob.class && entity.getPeriod() > 0) {
	    	int count = ConfigHelper.getNumerProperty(CONFIG_REPEAT);
	    	if(count <= 0) count = 1;
	    	builder.withSchedule(SimpleScheduleBuilder.
    				repeatMinutelyForTotalCount(count, entity.getPeriod()));
	    	if(isUseCalendar) {
	    		builder.modifiedByCalendar(CALENDAR_NAME);
	    	}
	    }
	    trigger = builder.build();
	    try {
	    	log.info("jobId:{} class:{} starting......", jobId, jobClazz);
			getScheduler().scheduleJob(job, trigger);
		} catch (SchedulerException e) {
			log.error(e.getMessage());
		}
	}
public void schedule(JobEntity entity) {
		AssertHelper.notNull(entity);
	    JobDataMap data = new JobDataMap(entity.getArgs());
	    data.put(KEY, entity.getId());
	    data.put(MODEL, entity.getModelName());
	    Class<? extends Job> jobClazz = null;
	    String jobId = "";
	    switch(entity.getJobType()) {
	    case 0:
	    	jobClazz = ExecutorJob.class;
	    	jobId = TYPE_EXECUTOR + entity.getTask().getId();
	    	break;
	    case 1:
	    	jobClazz = ReminderJob.class;
	    	jobId = TYPE_REMINDER + entity.getTask().getId();
	    	break;
	    }
	    if(jobClazz == null) {
	    	log.error("Quartz不支持的JOB类型:{}", entity.getJobType());
	    	return;
	    }
	    
	    JobDetail job = JobBuilder
	    		.newJob(jobClazz)
	    		.usingJobData(data)
	    		.withIdentity(jobId, GROUP)
	    		.build();
	    Trigger trigger = null;
	    TriggerBuilder<Trigger> builder = TriggerBuilder
	    		.newTrigger()
	    		.withIdentity(StringHelper.getPrimaryKey(), GROUP)
	    		.startAt(entity.getStartTime());
	    if(jobClazz == ReminderJob.class && entity.getPeriod() > 0) {
	    	int count = ConfigHelper.getNumerProperty(CONFIG_REPEAT);
	    	if(count <= 0) count = 1;
	    	builder.withSchedule(SimpleScheduleBuilder.
    				repeatMinutelyForTotalCount(count, entity.getPeriod()));
	    	if(isUseCalendar) {
	    		builder.modifiedByCalendar(CALENDAR_NAME);
	    	}
	    }
	    trigger = builder.build();
	    try {
	    	log.info("jobId:{} class:{} starting......", jobId, jobClazz);
			getScheduler().scheduleJob(job, trigger);
		} catch (SchedulerException e) {
			log.error(e.getMessage());
		}
	}
public void schedule ( JobEntity entity ) { AssertHelper . notNull ( entity ) ; JobDataMap data = new JobDataMap ( entity . getArgs ( ) ) ; data . put ( KEY , entity . getId ( ) ) ; data . put ( MODEL , entity . getModelName ( ) ) ; Class < ? extends Job > jobClazz = null ; String jobId = "" ; switch ( entity . getJobType ( ) ) { case 0 : jobClazz = ExecutorJob . class ; jobId = TYPE_EXECUTOR + entity . getTask ( ) . getId ( ) ; break ; case 1 : jobClazz = ReminderJob . class ; jobId = TYPE_REMINDER + entity . getTask ( ) . getId ( ) ; break ; } if ( jobClazz == null ) { log . error ( "Quartz不支持的JOB类型:{}", entity.get J bType( ) ); return ; } JobDetail job = JobBuilder . newJob ( jobClazz ) . usingJobData ( data ) . withIdentity ( jobId , GROUP ) . build ( ) ; Trigger trigger = null ; TriggerBuilder < Trigger > builder = TriggerBuilder . newTrigger ( ) . withIdentity ( StringHelper . getPrimaryKey ( ) , GROUP ) . startAt ( entity . getStartTime ( ) ) ; if ( jobClazz == ReminderJob . class && entity . getPeriod ( ) > 0 ) { int count = ConfigHelper . getNumerProperty ( CONFIG_REPEAT ) ; if ( count <= 0 ) count = 1 ; builder . withSchedule ( SimpleScheduleBuilder . repeatMinutelyForTotalCount ( count , entity . getPeriod ( ) ) ) ; if ( isUseCalendar ) { builder . modifiedByCalendar ( CALENDAR_NAME ) ; } } trigger = builder . build ( ) ; try { log . info ( "jobId:{} class:{} starting......" , jobId , jobClazz ) ; getScheduler ( ) . scheduleJob ( job , trigger ) ; } catch ( SchedulerException e ) { log . error ( e . getMessage ( ) ) ; } }
根据job实体调度具体的任务
根据job实体调度具体的任务