Java Code Examples for org.quartz.Scheduler#DEFAULT_GROUP

The following examples show how to use org.quartz.Scheduler#DEFAULT_GROUP . 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: AbstractTrigger.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <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;
}
 
Example 2
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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;
    
}
 
Example 3
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 4
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
    * <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;
}
 
Example 5
Source File: SchedulerServiceSupplier.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 6
Source File: CronTimer.java    From Raigad with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 7
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 8
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 9
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 10
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 11
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 12
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 13
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 14
Source File: CronTriggerFactoryBean.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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;
}
 
Example 15
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 16
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example 17
Source File: CronTriggerFactoryBean.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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;
}
 
Example 18
Source File: SimpleTriggerFactoryBean.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 19
Source File: SimpleTimer.java    From Raigad with Apache License 2.0 4 votes vote down vote up
/**
 * Run immediatly and dont do that again.
 */
public SimpleTimer(String name)
{
    this.trigger = new SimpleTrigger(name, Scheduler.DEFAULT_GROUP);
}
 
Example 20
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 3 votes vote down vote up
/**
 * <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);
}