Java Code Examples for org.quartz.impl.triggers.SimpleTriggerImpl#setRepeatInterval()

The following examples show how to use org.quartz.impl.triggers.SimpleTriggerImpl#setRepeatInterval() . 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: ScheduledInfo.java    From GOAi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 设置触发器
 */
private void initSimpleTrigger() {
    if (this.fixedRate <= 0 || this.delay < 0) {
        return;
    }
    SimpleTriggerImpl simpleTrigger = new SimpleTriggerImpl();
    simpleTrigger.setRepeatInterval(this.fixedRate);
    this.tip = "fixedRate: " + this.fixedRate + " ms delay: " + this.delay + " ms";
    // 无限次
    simpleTrigger.setRepeatCount(-1);
    simpleTrigger.setStartTime(new Date(System.currentTimeMillis() + this.delay));
    this.trigger = simpleTrigger;
    this.cron = "";
}
 
Example 2
Source File: SimpleTriggerFactoryBean.java    From spring-analysis-note with MIT License 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 != null ? this.name : toString());
	sti.setGroup(this.group);
	if (this.jobDetail != null) {
		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 3
Source File: SimpleTriggerFactoryBean.java    From java-technology-stack with MIT License 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 != null ? this.name : toString());
	sti.setGroup(this.group);
	if (this.jobDetail != null) {
		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 4
Source File: SimpleTriggerFactoryBean.java    From lams with GNU General Public License v2.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);
	if (this.jobDetail != null) {
		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 5
Source File: SimpleScheduleBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Build the actual Trigger -- NOT intended to be invoked by end users,
 * but will rather be invoked by a TriggerBuilder which this 
 * ScheduleBuilder is given to.
 * 
 * @see TriggerBuilder#withSchedule(ScheduleBuilder)
 */
@Override
public MutableTrigger build() {

    SimpleTriggerImpl st = new SimpleTriggerImpl();
    st.setRepeatInterval(interval);
    st.setRepeatCount(repeatCount);
    st.setMisfireInstruction(misfireInstruction);
    
    return st;
}
 
Example 6
Source File: SimpleTriggerSupport.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static OperableTrigger newTrigger(CompositeData cData) throws ParseException {
    SimpleTriggerImpl result = new SimpleTriggerImpl();
    result.setRepeatCount(((Integer) cData.get("repeatCount")).intValue());
    result.setRepeatInterval(((Long) cData.get("repeatInterval")).longValue());
    result.setTimesTriggered(((Integer) cData.get("timesTriggered")).intValue());
    TriggerSupport.initializeTrigger(result, cData);
    return result;
}
 
Example 7
Source File: SimpleTriggerSupport.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static OperableTrigger newTrigger(Map<String, Object> attrMap) throws ParseException {
    SimpleTriggerImpl result = new SimpleTriggerImpl();
    if(attrMap.containsKey("repeatCount")) {
        result.setRepeatCount(((Integer) attrMap.get("repeatCount")).intValue());
    }
    if(attrMap.containsKey("repeatInterval")) {
        result.setRepeatInterval(((Long) attrMap.get("repeatInterval")).longValue());
    }
    if(attrMap.containsKey("timesTriggered")) {
        result.setTimesTriggered(((Integer) attrMap.get("timesTriggered")).intValue());
    }
    TriggerSupport.initializeTrigger(result, attrMap);
    return result;
}
 
Example 8
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 9
Source File: RedisJobStore.java    From redis-quartz with MIT License 5 votes vote down vote up
private OperableTrigger toOperableTrigger(TriggerKey triggerKey, Map<String, String> trigger) {
	if (TRIGGER_TYPE_SIMPLE.equals(trigger.get(TRIGGER_TYPE))) {
		SimpleTriggerImpl simpleTrigger = new SimpleTriggerImpl();
		setOperableTriggerFields(triggerKey, trigger, simpleTrigger);
		if (trigger.get(REPEAT_COUNT) != null && !trigger.get(REPEAT_COUNT).isEmpty())
			simpleTrigger.setRepeatCount(Integer.parseInt(trigger.get(REPEAT_COUNT)));
		if (trigger.get(REPEAT_INTERVAL) != null && !trigger.get(REPEAT_INTERVAL).isEmpty())
			simpleTrigger.setRepeatInterval(Long.parseLong(trigger.get(REPEAT_INTERVAL)));
		if (trigger.get(TIMES_TRIGGERED) != null && !trigger.get(TIMES_TRIGGERED).isEmpty())
			simpleTrigger.setTimesTriggered(Integer.parseInt(trigger.get(TIMES_TRIGGERED)));
		
		return simpleTrigger;
	} else if (TRIGGER_TYPE_CRON.equals(trigger.get(TRIGGER_TYPE))) {
		CronTriggerImpl cronTrigger = new CronTriggerImpl();
		setOperableTriggerFields(triggerKey, trigger, cronTrigger);
		if (trigger.get(TIME_ZONE_ID) != null && !trigger.get(TIME_ZONE_ID).isEmpty())
			cronTrigger.getTimeZone().setID(trigger.get(TIME_ZONE_ID).isEmpty() ? null : trigger.get(TIME_ZONE_ID));
		try {
			if (trigger.get(CRON_EXPRESSION) != null && !trigger.get(CRON_EXPRESSION).isEmpty())
				cronTrigger.setCronExpression(trigger.get(CRON_EXPRESSION).isEmpty() ? null : trigger.get(CRON_EXPRESSION));
		} catch (ParseException ex) {
			log.warn("could not parse cron_expression: " + trigger.get(CRON_EXPRESSION) + " for trigger: " + createTriggerHashKey(triggerKey.getGroup(), triggerKey.getName()));
		}
		
		return cronTrigger;					
	} else { // other trigger types are not supported
		 throw new UnsupportedOperationException();
	}
}