All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.zw201913.quartzcluster.support.CronJobDefinition Maven / Gradle / Ivy

There is a newer version: 1.0.5.RELEASE
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy