org.quartz.Scheduler#DEFAULT_GROUP源码实例Demo

下面列出了org.quartz.Scheduler#DEFAULT_GROUP 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void afterPropertiesSet() {
	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}

	SimpleTriggerImpl sti = new SimpleTriggerImpl();
	sti.setName(this.name);
	sti.setGroup(this.group);
	sti.setJobKey(this.jobDetail.getKey());
	sti.setJobDataMap(this.jobDataMap);
	sti.setStartTime(this.startTime);
	sti.setRepeatInterval(this.repeatInterval);
	sti.setRepeatCount(this.repeatCount);
	sti.setPriority(this.priority);
	sti.setMisfireInstruction(this.misfireInstruction);
	sti.setDescription(this.description);
	this.simpleTrigger = sti;
}
 
@Override
public void afterPropertiesSet() throws ParseException {
	Assert.notNull(this.cronExpression, "Property 'cronExpression' is required");

	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}
	if (this.timeZone == null) {
		this.timeZone = TimeZone.getDefault();
	}

	CronTriggerImpl cti = new CronTriggerImpl();
	cti.setName(this.name != null ? this.name : toString());
	cti.setGroup(this.group);
	if (this.jobDetail != null) {
		cti.setJobKey(this.jobDetail.getKey());
	}
	cti.setJobDataMap(this.jobDataMap);
	cti.setStartTime(this.startTime);
	cti.setCronExpression(this.cronExpression);
	cti.setTimeZone(this.timeZone);
	cti.setCalendarName(this.calendarName);
	cti.setPriority(this.priority);
	cti.setMisfireInstruction(this.misfireInstruction);
	cti.setDescription(this.description);
	this.cronTrigger = cti;
}
 
源代码3 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Get the names of all the <code>{@link org.quartz.Trigger}s</code> in
 * the given group.
 * </p>
 */
public String[] getTriggerNames(SchedulingContext ctxt, String groupName)
    throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    return resources.getJobStore().getTriggerNames(ctxt, groupName);
}
 
源代码4 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Trigger the identified <code>{@link org.quartz.Job}</code> (execute it
 * now) - with a non-volatile trigger.
 * </p>
 */
public void triggerJob(SchedulingContext ctxt, String jobName,
        String groupName, JobDataMap data) throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    Trigger trig = new org.quartz.SimpleTrigger(newTriggerId(),
            Scheduler.DEFAULT_MANUAL_TRIGGERS, jobName, groupName,
            new Date(), null, 0, 0);
    trig.setVolatility(false);
    trig.computeFirstFireTime(null);
    if(data != null) {
        trig.setJobDataMap(data);
    }

    boolean collision = true;
    while (collision) {
        try {
            resources.getJobStore().storeTrigger(ctxt, trig, false);
            collision = false;
        } catch (ObjectAlreadyExistsException oaee) {
            trig.setName(newTriggerId());
        }
    }

    notifySchedulerThread(trig.getNextFireTime().getTime());
    notifySchedulerListenersSchduled(trig);
}
 
@Override
public void afterPropertiesSet() throws ParseException {
	Assert.notNull(this.cronExpression, "Property 'cronExpression' is required");

	if (this.name == null) {
		this.name = this.beanName;
	}
	if (this.group == null) {
		this.group = Scheduler.DEFAULT_GROUP;
	}
	if (this.jobDetail != null) {
		this.jobDataMap.put("jobDetail", this.jobDetail);
	}
	if (this.startDelay > 0 || this.startTime == null) {
		this.startTime = new Date(System.currentTimeMillis() + this.startDelay);
	}
	if (this.timeZone == null) {
		this.timeZone = TimeZone.getDefault();
	}

	CronTriggerImpl cti = new CronTriggerImpl();
	cti.setName(this.name != null ? this.name : toString());
	cti.setGroup(this.group);
	if (this.jobDetail != null) {
		cti.setJobKey(this.jobDetail.getKey());
	}
	cti.setJobDataMap(this.jobDataMap);
	cti.setStartTime(this.startTime);
	cti.setCronExpression(this.cronExpression);
	cti.setTimeZone(this.timeZone);
	cti.setCalendarName(this.calendarName);
	cti.setPriority(this.priority);
	cti.setMisfireInstruction(this.misfireInstruction);
	cti.setDescription(this.description);
	this.cronTrigger = cti;
}
 
源代码6 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Resume (un-pause) all of the <code>{@link Trigger}s</code> in the
 * given group.
 * </p>
 * 
 * <p>
 * If any <code>Trigger</code> missed one or more fire-times, then the
 * <code>Trigger</code>'s misfire instruction will be applied.
 * </p>
 *  
 */
public void resumeTriggerGroup(SchedulingContext ctxt, String groupName)
    throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    resources.getJobStore().resumeTriggerGroup(ctxt, groupName);
    notifySchedulerThread(0L);
    notifySchedulerListenersResumedTrigger(null, groupName);
}
 
源代码7 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Trigger the identified <code>{@link org.quartz.Job}</code> (execute it
 * now) - with a volatile trigger.
 * </p>
 */
public void triggerJobWithVolatileTrigger(SchedulingContext ctxt,
        String jobName, String groupName, JobDataMap data) throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    Trigger trig = new org.quartz.SimpleTrigger(newTriggerId(),
            Scheduler.DEFAULT_MANUAL_TRIGGERS, jobName, groupName,
            new Date(), null, 0, 0);
    trig.setVolatility(true);
    trig.computeFirstFireTime(null);
    if(data != null) {
        trig.setJobDataMap(data);
    }
    
    boolean collision = true;
    while (collision) {
        try {
            resources.getJobStore().storeTrigger(ctxt, trig, false);
            collision = false;
        } catch (ObjectAlreadyExistsException oaee) {
            trig.setName(newTriggerId());
        }
    }

    notifySchedulerThread(trig.getNextFireTime().getTime());
    notifySchedulerListenersSchduled(trig);
}
 
源代码8 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Get the <code>{@link Trigger}</code> instance with the given name and
 * group.
 * </p>
 */
public Trigger getTrigger(SchedulingContext ctxt, String triggerName,
        String triggerGroup) throws SchedulerException {
    validateState();

    if(triggerGroup == null) {
        triggerGroup = Scheduler.DEFAULT_GROUP;
    }
    
    return resources.getJobStore().retrieveTrigger(ctxt, triggerName,
            triggerGroup);
}
 
源代码9 项目: lams   文件: AbstractTrigger.java
/**
 * <p>
 * Set the name of this <code>Trigger</code>. 
 * </p>
 * 
 * @param group if <code>null</code>, Scheduler.DEFAULT_GROUP will be used.
 * 
 * @exception IllegalArgumentException
 *              if group is an empty string.
 */
public void setGroup(String group) {
    if (group != null && group.trim().length() == 0) {
        throw new IllegalArgumentException(
                "Group name cannot be an empty string.");
    }

    if(group == null) {
        group = Scheduler.DEFAULT_GROUP;
    }

    this.group = group;
    this.key = null;
}
 
源代码10 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Pause the <code>{@link org.quartz.JobDetail}</code> with the given
 * name - by pausing all of its current <code>Trigger</code>s.
 * </p>
 *  
 */
public void pauseJob(SchedulingContext ctxt, String jobName,
        String groupName) throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }

    resources.getJobStore().pauseJob(ctxt, jobName, groupName);
    notifySchedulerThread(0L);
    notifySchedulerListenersPausedJob(jobName, groupName);
}
 
源代码11 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Get the <code>{@link JobDetail}</code> for the <code>Job</code>
 * instance with the given name and group.
 * </p>
 */
public JobDetail getJobDetail(SchedulingContext ctxt, String jobName,
        String jobGroup) throws SchedulerException {
    validateState();

    if(jobGroup == null) {
        jobGroup = Scheduler.DEFAULT_GROUP;
    }
    
    return resources.getJobStore().retrieveJob(ctxt, jobName, jobGroup);
}
 
源代码12 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Get the names of all the <code>{@link org.quartz.Job}s</code> in the
 * given group.
 * </p>
 */
public String[] getJobNames(SchedulingContext ctxt, String groupName)
    throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    return resources.getJobStore().getJobNames(ctxt, groupName);
}
 
源代码13 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Pause all of the <code>{@link org.quartz.JobDetail}s</code> in the
 * given group - by pausing all of their <code>Trigger</code>s.
 * </p>
 *  
 */
public void pauseJobGroup(SchedulingContext ctxt, String groupName)
    throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    resources.getJobStore().pauseJobGroup(ctxt, groupName);
    notifySchedulerThread(0L);
    notifySchedulerListenersPausedJob(null, groupName);
}
 
源代码14 项目: Raigad   文件: CronTimer.java
public Trigger getTrigger() throws ParseException {
    if (StringUtils.isNotBlank(triggerName)) {
        return new CronTrigger("CronTrigger" + triggerName, Scheduler.DEFAULT_GROUP, cronExpression);
    } else {
        return new CronTrigger("CronTrigger", Scheduler.DEFAULT_GROUP, cronExpression);
    }
}
 
源代码15 项目: Knowage-Server   文件: SchedulerServiceSupplier.java
/**
 * Exist job definition.
 * 
 * @param jobName the job name
 * @param jobGroup the job group
 * 
 * @return the string
 */
public   String existJobDefinition(String jobName, String jobGroup) {
	StringBuffer buffer = new StringBuffer("<JOB_EXISTANCE  ");
	try{
		Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
		if (jobName == null || jobName.trim().equals("")) {
			SpagoBITracer.critical(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), 
								   "existJobDefinition", "Missing job name request parameter!");
			throw new Exception("Missing job name request parameter!");
		}
		if (jobGroup == null || jobGroup.trim().equals("")) {
			SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), 
								"existJobDefinition", "Missing job group name! Using default group...");
			jobGroup = Scheduler.DEFAULT_GROUP;
		}
		JobDetail aJob = scheduler.getJobDetail(jobName, jobGroup);
		if (aJob == null) {
			buffer.append(" exists=\"false\" />");
		} else {
			buffer.append(" exists=\"true\" />");
		}
	} catch (Exception e) {
		SpagoBITracer.critical(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), 
				   			  "existJobDefinition", "Error while checking existence of job", e);
		buffer = new StringBuffer("<JOB_EXISTANCE/> ");
	}
	return buffer.toString();
}
 
源代码16 项目: AsuraFramework   文件: QuartzScheduler.java
/**
    * <p>
    * Delete the identified <code>Job</code> from the Scheduler - and any
    * associated <code>Trigger</code>s.
    * </p>
    * 
    * @return true if the Job was found and deleted.
    * @throws SchedulerException
    *           if there is an internal Scheduler error.
    */
public boolean deleteJob(SchedulingContext ctxt, String jobName,
		String groupName) throws SchedulerException {
	validateState();

	if (groupName == null) {
		groupName = Scheduler.DEFAULT_GROUP;
	}

	boolean result = false;
	
	Trigger[] triggers = getTriggersOfJob(ctxt, jobName, groupName);
	for (Trigger trigger : triggers) {
		if (!unscheduleJob(ctxt, trigger.getName(), trigger.getGroup())) {
			StringBuilder sb = new StringBuilder().append(
					"Unable to unschedule trigger [").append(
					trigger.getKey()).append("] while deleting job [")
					.append(groupName).append(".").append(jobName).append(
							"]");
			throw new SchedulerException(sb.toString());
		}
		result = true;
	}

	result = resources.getJobStore().removeJob(ctxt, jobName, groupName) || result;
	if (result) {
		notifySchedulerThread(0L);
		notifySchedulerListenersJobDeleted(jobName, groupName);
	}
	return result;
}
 
源代码17 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Resume (un-pause) the <code>{@link Trigger}</code> with the given
 * name.
 * </p>
 * 
 * <p>
 * If the <code>Trigger</code> missed one or more fire-times, then the
 * <code>Trigger</code>'s misfire instruction will be applied.
 * </p>
 *  
 */
public void resumeTrigger(SchedulingContext ctxt, String triggerName,
        String groupName) throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    resources.getJobStore().resumeTrigger(ctxt, triggerName, groupName);
    notifySchedulerThread(0L);
    notifySchedulerListenersResumedTrigger(triggerName, groupName);
}
 
源代码18 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Remove (delete) the <code>{@link org.quartz.Trigger}</code> with the
 * given name, and store the new given one - which must be associated
 * with the same job.
 * </p>
 * 
 * @param triggerName
 *          The name of the <code>Trigger</code> to be removed.
 * @param groupName
 *          The group name of the <code>Trigger</code> to be removed.
 * @param newTrigger
 *          The new <code>Trigger</code> to be stored.
 * @return <code>null</code> if a <code>Trigger</code> with the given
 *         name & group was not found and removed from the store, otherwise
 *         the first fire time of the newly scheduled trigger.
 */
public Date rescheduleJob(SchedulingContext ctxt, String triggerName,
        String groupName, Trigger newTrigger) throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }

    newTrigger.validate();

    Calendar cal = null;
    if (newTrigger.getCalendarName() != null) {
        cal = resources.getJobStore().retrieveCalendar(ctxt,
                newTrigger.getCalendarName());
    }
    Date ft = newTrigger.computeFirstFireTime(cal);

    if (ft == null) {
        throw new SchedulerException(
                "Based on configured schedule, the given trigger will never fire.",
                SchedulerException.ERR_CLIENT_ERROR);
    }
    
    if (resources.getJobStore().replaceTrigger(ctxt, triggerName, groupName, newTrigger)) {
        notifySchedulerThread(newTrigger.getNextFireTime().getTime());
        notifySchedulerListenersUnscheduled(triggerName, groupName);
        notifySchedulerListenersSchduled(newTrigger);
    } else {
        return null;
    }

    return ft;
    
}
 
源代码19 项目: Raigad   文件: SimpleTimer.java
/**
 * Run immediatly and dont do that again.
 */
public SimpleTimer(String name)
{
    this.trigger = new SimpleTrigger(name, Scheduler.DEFAULT_GROUP);
}
 
源代码20 项目: AsuraFramework   文件: QuartzScheduler.java
/**
 * <p>
 * Resume (un-pause) the <code>{@link org.quartz.JobDetail}</code> with
 * the given name.
 * </p>
 * 
 * <p>
 * If any of the <code>Job</code>'s<code>Trigger</code> s missed one
 * or more fire-times, then the <code>Trigger</code>'s misfire
 * instruction will be applied.
 * </p>
 *  
 */
public void resumeJob(SchedulingContext ctxt, String jobName,
        String groupName) throws SchedulerException {
    validateState();

    if(groupName == null) {
        groupName = Scheduler.DEFAULT_GROUP;
    }
    
    resources.getJobStore().resumeJob(ctxt, jobName, groupName);
    notifySchedulerThread(0L);
    notifySchedulerListenersResumedJob(jobName, groupName);
}