com.github.lontime.extquartz.impl.beans.JobDetailBean Maven / Gradle / Ivy
package com.github.lontime.extquartz.impl.beans;
import lombok.Getter;
import lombok.Setter;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.impl.JobDetailImpl;
/**
* TriggerBean.
* @see JobDetailImpl
* @author lontime
* @since 1.0
*/
@Getter
@Setter
public class JobDetailBean {
private String name;
private String group;
private String description;
private String jobClass;
private Boolean durable;
private Boolean requestsRecovery;
public static JobDetailBean from(JobDetail jobDetail) {
final JobDetailBean bean = new JobDetailBean();
bean.setName(jobDetail.getKey().getName());
bean.setGroup(jobDetail.getKey().getGroup());
bean.setDescription(jobDetail.getDescription());
bean.setJobClass(jobDetail.getJobClass().getName());
bean.setDurable(jobDetail.isDurable());
bean.setRequestsRecovery(jobDetail.requestsRecovery());
return bean;
}
public JobDetail toJobDetail(JobDetailBean bean) {
final JobDetailImpl jobDetail = new JobDetailImpl();
jobDetail.setName(bean.getName());
jobDetail.setGroup(bean.getGroup());
jobDetail.setDescription(bean.getDescription());
try {
jobDetail.setJobClass((Class) Class.forName(bean.getJobClass()));
} catch (Exception e) {
e.printStackTrace();
}
if (bean.getDurable() != null) {
jobDetail.setDurability(bean.getDurable());
}
if (bean.getRequestsRecovery() != null) {
jobDetail.setRequestsRecovery(bean.getRequestsRecovery());
}
return jobDetail;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy