本文整理汇总了Java中org.quartz.TriggerBuilder.endAt方法的典型用法代码示例。如果您正苦于以下问题:Java TriggerBuilder.endAt方法的具体用法?Java TriggerBuilder.endAt怎么用?Java TriggerBuilder.endAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.TriggerBuilder
的用法示例。
在下文中一共展示了TriggerBuilder.endAt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTrigger
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@Override
public Trigger getTrigger() {
Checker.require(triggerKey).notNull();
TriggerBuilder<Trigger> triggerBuilder = newTrigger().withIdentity(triggerKey);
if (getStartTime() == null) {
triggerBuilder.startNow();
} else {
triggerBuilder.startAt(getStartTime());
}
if (getEndTime() != null) {
triggerBuilder.endAt(getEndTime());
}
if (isRepeatable()) {
SimpleScheduleBuilder scheduleBuilder = simpleSchedule();
scheduleBuilder.withIntervalInSeconds(getIntervalInSeconds());
if (isRepeatForever()) {
scheduleBuilder.repeatForever();
} else {
scheduleBuilder.withRepeatCount(getRepeatCount());
}
triggerBuilder.withSchedule(scheduleBuilder);
}
return triggerBuilder.build();
}
示例2: createCronTrigger
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
/**
* 创建复杂触发器
* @param jobName 作业名
* @param groupName 组名
* @param cronExpression cron表达式
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
public static Trigger createCronTrigger(ExecutionContext executionContext, String cronExpression,Date startTime,Date endTime) {
TriggerBuilder<CronTrigger> triggerBuilder=newTrigger()
.withIdentity(GuidUtil.CreateGuid(), executionContext.getProcessDefinition().getId())
.withSchedule(cronSchedule(cronExpression));
if(startTime!=null){
triggerBuilder.startAt(startTime);
}
if(endTime!=null){
triggerBuilder.endAt(endTime);
}
CronTrigger trigger = triggerBuilder
.build();
return trigger;
}
示例3: createCronTrigger
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
/**
* 创建复杂触发器
*
* @param jobName
* 作业名
* @param groupName
* 组名
* @param cronExpression
* cron表达式
* @param startTime
* 开始时间
* @param endTime
* 结束时间
* @return
*/
public final static Trigger createCronTrigger(ListenerExecutionContext executionContext,
String cronExpression, Date startTime, Date endTime) {
TriggerBuilder<CronTrigger> triggerBuilder = newTrigger().withIdentity(GuidUtil.CreateGuid(), executionContext.getProcessInstanceId()).withSchedule(cronSchedule(cronExpression));
if (startTime != null) {
triggerBuilder.startAt(startTime);
}
if (endTime != null) {
triggerBuilder.endAt(endTime);
}
CronTrigger trigger = triggerBuilder.build();
return trigger;
}
示例4: scheduleCronTask
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
/**
* Schedules a new task using supplied cron expression.
*
* @param inJobName Name of new task.
* @param inTriggerName Name of trigger for the new task.
* @param inGroupName Name of group to which new task and trigger is to belong.
* @param inJobClass The job class that will be executed when the new task triggers.
* @param inCronExpression Cron expression specifying when task is to be
* executed.
* @param inJobDataMap Map holding information to be passed to the
* job being executed. Contents of map will be copied.
* @param inStartDate Point in time after which task is to start being
* scheduled for execution, or null if task is to be scheduled now.
* @param inEndDate Point in time after which the task will no longer
* be scheduled for execution, or null if task is to be scheduled
* indefinitely.
* @throws Exception If error occurs scheduling task.
*/
public void scheduleCronTask(final String inJobName, final String inTriggerName, final String inGroupName,
final Class<? extends Job> inJobClass, final String inCronExpression, final Map<String, Object> inJobDataMap,
final Date inStartDate, final Date inEndDate) throws Exception {
final JobDetail theJob = JobBuilder.newJob(inJobClass).withIdentity(inJobName, inGroupName).build();
/* Copy job data from the supplied map to the actual job data map. */
theJob.getJobDataMap().putAll(inJobDataMap);
/*
* Create builder that will create a schedule for the new task using
* the supplied cron expression.
*/
final CronScheduleBuilder theScheduleBuilder = CronScheduleBuilder.cronSchedule(inCronExpression);
/*
* Create a trigger builder using the schedule builder,
* the start and end dates, if supplied.
*/
TriggerBuilder<CronTrigger> theTriggerBuilder =
TriggerBuilder.newTrigger().withIdentity(inTriggerName, inGroupName).withSchedule(theScheduleBuilder);
/* If no start date supplied, start now, else start at start date. */
if (inStartDate == null) {
theTriggerBuilder = theTriggerBuilder.startNow();
} else {
theTriggerBuilder = theTriggerBuilder.startAt(inStartDate);
}
/* If an end date supplied end at that date, otherwise continue indefinitely. */
theTriggerBuilder = theTriggerBuilder.endAt(inEndDate);
/* Schedule the new task. */
mTaskScheduler.scheduleJob(theJob, theTriggerBuilder.build());
LOGGER.debug("Scheduled task {} in group {}", inJobName, inGroupName);
}
示例5: createTrigger
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
protected Trigger createTrigger(JobDataMap data, Date start, int interval,
int repeat, Date end) {
TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
if (data != null) {
triggerBuilder.usingJobData(data);
}
if (interval > 0) {
SimpleScheduleBuilder schedule = SimpleScheduleBuilder
.simpleSchedule();
schedule.withIntervalInMilliseconds(interval).withRepeatCount(
repeat);
triggerBuilder.withSchedule(schedule);
}
if (start != null) {
triggerBuilder.startAt(start);
} else {
triggerBuilder.startNow();
}
if (end != null) {
triggerBuilder.endAt(end);
}
return triggerBuilder.build();
}
示例6: initTrigger
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
protected Trigger initTrigger(String name, Options<ScheduleOption> opts) {
TriggerBuilder<Trigger> builder = TriggerBuilder.newTrigger()
.withIdentity(name, name());
if (opts.has(AT)) {
builder.startAt(opts.getDate(AT));
} else if (opts.has(IN)) {
builder.startAt(new java.util.Date(System.currentTimeMillis() + opts.getLong(IN)));
} else {
builder.startNow();
}
if (opts.has(UNTIL)) {
builder.endAt(opts.getDate(UNTIL));
}
if (opts.has(CRON)) {
builder.withSchedule(CronScheduleBuilder.cronSchedule(opts.getString(CRON)));
} else if (opts.has(EVERY)) {
SimpleScheduleBuilder schedule =
SimpleScheduleBuilder.simpleSchedule()
.withIntervalInMilliseconds(opts.getInt(EVERY));
if (opts.has(LIMIT)) {
schedule.withRepeatCount(opts.getInt(LIMIT) - 1);
} else {
schedule.repeatForever();
}
builder.withSchedule(schedule);
}
return builder.build();
}
示例7: addScript
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
private void addScript(ScheduledScript script) throws Exception {
TriggerBuilder triggerBuilder = TriggerBuilder.newTrigger();
triggerBuilder.withIdentity(script.getId());
if (script.getCron() != null) {
triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(script.getCron()));
}
if (script.getAt() != null) {
triggerBuilder.startAt(script.getAt());
}
if (script.getUntil() != null) {
triggerBuilder.endAt(script.getUntil());
}
Trigger trigger = triggerBuilder.build();
JobDataMap dataMap = new JobDataMap();
dataMap.put(SCRIPT_DATAMAP_KEY, script);
dataMap.put(SCRIPT_MANAGER_DATAMAP_KEY, scriptManager);
JobBuilder jobBuilder = JobBuilder.newJob();
jobBuilder.withIdentity(script.getId());
jobBuilder.ofType(ScriptJob.class);
jobBuilder.setJobData(dataMap);
scheduler.scheduleJob(jobBuilder.build(), trigger);
}
示例8: addTrigger
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
public JSONResult addTrigger(String schedulerName, String jobName, String jobGroup,
String triggerName, String triggerGroup, String cronExpression, String description,
String priority, Date startDate, Date endDate, Map<String, Object> dataMap) {
try {
Assert.notEmpty(schedulerName, "schedulerName can not be empty");
Assert.notEmpty(jobName, "jobName can not be empty");
Assert.notEmpty(jobGroup, "jobGroup can not be empty");
Assert.notEmpty(triggerName, "triggerName can not be empty");
Assert.notEmpty(triggerGroup, "triggerGroup can not be empty");
Assert.isCronExpression(cronExpression, "cronExpression is error");
TriggerBuilder<Trigger> triggerTriggerBuilder = TriggerBuilder.newTrigger();
triggerTriggerBuilder = triggerTriggerBuilder.withIdentity(triggerName, triggerGroup);
if (!StringUtils.isEmpty(description)) {
triggerTriggerBuilder = triggerTriggerBuilder.withDescription(description);
}
if (!StringUtils.isEmpty(priority) && StringUtils.isInteger(priority)) {
Assert.isInteger(priority, "priority must be int");
triggerTriggerBuilder.withPriority(Integer.parseInt(priority));
}
if (startDate != null) {
triggerTriggerBuilder.startAt(startDate);
}
if (endDate != null) {
triggerTriggerBuilder.endAt(endDate);
}
//jobDataMap
if (dataMap != null && dataMap.size() > 0) {
JobDataMap jobDataMap = new JobDataMap();
for (Map.Entry<String, Object> dataKey : dataMap.entrySet()) {
if (!StringUtils.isEmpty(dataKey.getKey())) {
jobDataMap.put(dataKey.getKey(), dataKey.getValue());
}
}
triggerTriggerBuilder.usingJobData(jobDataMap);
}
triggerTriggerBuilder.forJob(jobName, jobGroup);
CronTrigger trigger = triggerTriggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cronExpression))
.build();
//JobDetail jobDetail = QuartzWebManager.getJob(schedulerName, jobName, jobGroup);
// 存在更新不存在,添加
if (!QuartzWebManager.checkTriggerExists(schedulerName, triggerName, triggerGroup)) {
QuartzWebManager.addTriggerForJob(schedulerName, trigger);
} else {
QuartzWebManager.updateTriggerForJob(schedulerName, trigger);
}
return JSONResult.build(JSONResult.RESULT_CODE_SUCCESS, "ok");
} catch (Exception e) {
e.printStackTrace();
return JSONResult.build(JSONResult.RESULT_CODE_ERROR, e.getMessage());
}
}
示例9: setTriggerParam
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
/**
* 设置trigger
*
* @param job
* @param triggerKey
* @param trigger
* @param triggerBuilder
*/
public Trigger setTriggerParam(ScheduleJob job, TriggerKey triggerKey, TriggerBuilder triggerBuilder,
Trigger trigger) {
if (job.getTriggerType().equals("CronTrigger")) {
CronScheduleBuilder cronBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
// 按新的cronExpression表达式构建一个新的trigger
if (job.getStartTime() != null)
triggerBuilder.startAt(job.getStartTime());
if (job.getEndTime() != null)
triggerBuilder.endAt(job.getEndTime());
//int index=job.getDesc().indexOf(";repeatType:")>-1?job.getDesc().indexOf(";repeatType:"):job.getDesc().length();
trigger = triggerBuilder.withIdentity(triggerKey).withSchedule(cronBuilder).withDescription(
job.getDesc()).build();
} else if (job.getTriggerType().equals("SimpleTrigger")) {
SimpleScheduleBuilder simpleBuilder = SimpleScheduleBuilder.simpleSchedule();
if (job.getStartTime() != null)
triggerBuilder.startAt(job.getStartTime());
if (job.getEndTime() != null)
triggerBuilder.endAt(job.getEndTime());
if (StrUtil.isNotBlank(job.getRepeatType())) {
if (job.getRepeatType().equals("repeatForever")) {
simpleBuilder=simpleBuilderForever(simpleBuilder,job);
}
else if (job.getRepeatType().equals("repeatHourlyForever")) {
if (job.getRepeatInterval() != null)
simpleBuilder = simpleBuilder.repeatHourlyForever(job.getRepeatInterval());
else
simpleBuilder = simpleBuilder.repeatHourlyForever();
} else if (job.getRepeatType().equals("repeatMinutelyForever")) {
if (job.getRepeatInterval() != null)
simpleBuilder = simpleBuilder.repeatMinutelyForever(job.getRepeatInterval());
else
simpleBuilder = simpleBuilder.repeatMinutelyForever();
} else if (job.getRepeatType().equals("repeatSecondlyForever")) {
if (job.getRepeatInterval() != null)
simpleBuilder = simpleBuilder.repeatSecondlyForever(job.getRepeatInterval());
else
simpleBuilder = simpleBuilder.repeatSecondlyForever();
} else if (job.getRepeatType().equals("repeatHourlyForTotalCount")) {
if (job.getRepeatCount() != null && job.getRepeatInterval() != null)
simpleBuilder = simpleBuilder.repeatHourlyForTotalCount(job.getRepeatCount(), job
.getRepeatInterval());
else if (job.getRepeatCount() != null)
simpleBuilder = simpleBuilder.repeatHourlyForTotalCount(job.getRepeatCount());
} else if (job.getRepeatType().equals("repeatMinutelyForTotalCount")) {
if (job.getRepeatCount() != null && job.getRepeatInterval() != null)
simpleBuilder = simpleBuilder.repeatMinutelyForTotalCount(job.getRepeatCount(), job
.getRepeatInterval());
else if (job.getRepeatCount() != null)
simpleBuilder = simpleBuilder.repeatMinutelyForTotalCount(job.getRepeatCount());
} else if (job.getRepeatType().equals("repeatSecondlyForTotalCount")) {
if (job.getRepeatCount() != null && job.getRepeatInterval() != null)
simpleBuilder = simpleBuilder.repeatSecondlyForTotalCount(job.getRepeatCount(), job
.getRepeatInterval());
else if (job.getRepeatCount() != null)
simpleBuilder = simpleBuilder.repeatSecondlyForTotalCount(job.getRepeatCount());
}
}
if(StrUtil.isEmpty(job.getDesc()))
job.setDesc("");
int index=job.getDesc().indexOf(";repeatType:")>-1?job.getDesc().indexOf(";repeatType:"):job.getDesc().length();
trigger = triggerBuilder.withIdentity(triggerKey).withSchedule(simpleBuilder).withDescription(
job.getDesc().substring(0,index) + ";repeatType:" + job.getRepeatType()).build();
/*trigger = triggerBuilder.withIdentity(triggerKey).withSchedule(simpleBuilder).withDescription(
job.getDesc()).build();*/
}
return trigger;
}
示例10: configureTriggerJob
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
private Trigger configureTriggerJob(String jobName, String jobGroup, Job job) {
TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
// base trigger configuration
triggerBuilder.withIdentity(jobName, jobGroup);
if (job.getStartTime() != null)
triggerBuilder.startAt(job.getStartTime());
else {
if (job.getActive())
triggerBuilder.startNow();
}
if (job.getEndTime() != null)
triggerBuilder.endAt(job.getEndTime());
triggerBuilder.withPriority(job.getJobTriggerPriority());
// propietary trigger configuration
if (job.getJobTriggerType().getCode().equals(Job.JOB_TRIGGER_TYPE.SIMPLE.name())) {
SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
if (job.getJobInterval() != null) {
if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.SECOND.name()))
simpleScheduleBuilder.withIntervalInSeconds(job.getJobInterval());
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.MINUTE.name()))
simpleScheduleBuilder.withIntervalInMinutes(job.getJobInterval());
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.HOUR.name()))
simpleScheduleBuilder.withIntervalInHours(job.getJobInterval());
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.DAY.name()))
simpleScheduleBuilder.withIntervalInHours(job.getJobInterval() * 24);
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.WEEK.name()))
simpleScheduleBuilder.withIntervalInHours(job.getJobInterval() * 24 * 7);
}
if (job.getRepeatCount() != null)
simpleScheduleBuilder.withRepeatCount(job.getRepeatCount());
else
simpleScheduleBuilder.repeatForever();
triggerBuilder.withSchedule(simpleScheduleBuilder);
}
else if (job.getJobTriggerType().getCode().equals(Job.JOB_TRIGGER_TYPE.CRON.name())) {
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
triggerBuilder.withSchedule(cronScheduleBuilder);
}
return triggerBuilder.build();
}