com.github.zw201913.quartzcluster.support.CronJobDefinition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quartz-cluster Show documentation
Show all versions of quartz-cluster Show documentation
extended quartz distributed timing tasks
package com.github.zw201913.quartzcluster.support;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.quartz.CronScheduleBuilder;
import org.quartz.JobDetail;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
/** @author zouwei */
@Slf4j
@Data
public class CronJobDefinition extends JobDefinition {
private static final long serialVersionUID = 6940446397330926681L;
/** 执行策略 */
private String cronExpression;
@Override
protected Trigger trigger(JobDetail jobDetail) {
return TriggerBuilder.newTrigger()
.forJob(jobDetail)
.withIdentity(triggerKey())
.withSchedule(CronScheduleBuilder.cronSchedule(getCronExpression()))
.build();
}
}