本文整理汇总了Java中org.quartz.Scheduler.deleteJob方法的典型用法代码示例。如果您正苦于以下问题:Java Scheduler.deleteJob方法的具体用法?Java Scheduler.deleteJob怎么用?Java Scheduler.deleteJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.Scheduler
的用法示例。
在下文中一共展示了Scheduler.deleteJob方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* @Description 移除一个任务(使用默认的任务组名,触发器名,触发器组名)
* @param jobName
*
*
*/
public static void removeJob(String jobName) {
TriggerKey triggerKey = TriggerKey.triggerKey(
jobName, TRIGGER_GROUP_NAME);
JobKey jobKey = JobKey.jobKey(jobName, JOB_GROUP_NAME);
try {
Scheduler sched = gSchedulerFactory.getScheduler();
Trigger trigger = (Trigger) sched.getTrigger(triggerKey);
if (trigger == null) {
return;
}
sched.pauseTrigger(triggerKey);;// 停止触发器
sched.unscheduleJob(triggerKey);// 移除触发器
sched.deleteJob(jobKey);// 删除任务
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: deleteJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
@Transactional
@Override
public boolean deleteJob(JobKey jobKey) {
try {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
return scheduler.deleteJob(jobKey);
} catch (SchedulerException e) {
throw new ServiceException(e);
}
}
示例3: deleteScheduleJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 删除定时任务
*/
public static void deleteScheduleJob(Scheduler scheduler, Long jobId) {
try {
scheduler.deleteJob(getJobKey(jobId));
} catch (SchedulerException e) {
throw new RRException("删除定时任务失败", e);
}
}
示例4: removeJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 删除Job和下面所有Trigger
* @param jobDetail
* @param scheduler
* @throws SchedulerException
*/
public static void removeJob(JobDetail jobDetail, Scheduler scheduler) throws SchedulerException {
// 暂停
pauseJob(jobDetail, scheduler);
// 移除
scheduler.deleteJob(jobDetail.getKey());
}
示例5: deleteJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 删除一个job
*
* @param scheduleJob
* @throws SchedulerException
*/
public void deleteJob(ScheduleJob scheduleJob) throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
JobKey jobKey = JobKey.jobKey(scheduleJob.getName(), scheduleJob.getGroup());
scheduler.deleteJob(jobKey);
}
示例6: executeScheduleJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 执行计划任务
* @param job
* @param trigger
* @return
* @throws SchedulerException
*/
public static ScheduleJobResult executeScheduleJob(JobDetail job, Trigger trigger) throws SchedulerException {
ScheduleJobResult scheduleJobResult = new ScheduleJobResult();
//判断是否满足计划任务的创建条件
if(job.getKey() == null || trigger.getKey() == null || job.getJobDataMap() == null){
scheduleJobResult.setScheduleJobStatus(ScheduleJobStatus.FAILED);
//不满足计划任务的创建条件,返回scheduleJobResult值类
return scheduleJobResult;
}
scheduleJobResult.setJobDetail(job);
scheduleJobResult.setTrigger(trigger);
//开始分配计划任务
Scheduler scheduler = SchedulerFactory.getScheduler();
//开始判断是否存在相同的计划任务
if(scheduler.checkExists(job.getKey())){
log.info("存在相同的计划任务:{}",job.getKey());
scheduler.deleteJob(job.getKey());
scheduleJobResult.setJobKey(job.getKey());
scheduleJobResult.setTriggerKey(trigger.getKey());
scheduleJobResult.setScheduleJobStatus(ScheduleJobStatus.ISEXIST);
scheduler.scheduleJob(job,trigger);
scheduler.start();
}else{
scheduler.scheduleJob(job,trigger);
scheduler.start();
scheduleJobResult.setJobKey(job.getKey());
scheduleJobResult.setTriggerKey(trigger.getKey());
scheduleJobResult.setScheduleJobStatus(ScheduleJobStatus.SUCCESS);
}
//计划任务分配成功
return scheduleJobResult;
}
示例7: removeJobFromScheduler
import org.quartz.Scheduler; //导入方法依赖的package包/类
public void removeJobFromScheduler(String jobDefId,String companyId) throws SchedulerException {
Scheduler scheduler=schedulerService.retrieveScheduler();
JobKey jobKey=new JobKey(JOB_PREFIX+jobDefId,companyId);
TriggerKey triggerKey=new TriggerKey(TRIGGER_PREFIX+jobDefId,companyId);
if(scheduler.checkExists(jobKey)){
scheduler.pauseTrigger(triggerKey);
scheduler.unscheduleJob(triggerKey);
scheduler.deleteJob(jobKey);
}
}
示例8: maybeScheduleArchiveJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Schedule the archiving job based on the interval defined in the DB.
*
* If archiving is disabled, deletes the archiving job.
*/
@Override
public void maybeScheduleArchiveJob() {
try {
BaseDtoResponse<JobsArchiveDto> reponse = this.jobsArchiveService.dispatch(new Request() {
});
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
boolean doesJobExists = scheduler.checkExists(new JobKey(ARCHIVE_JOB_NAME,
ARCHIVE_GROUP_NAME));
if (reponse.getDto().getAutoSchedule() && !doesJobExists) {
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put(GetJobsArchiveServiceApi.class.getName(), this.jobsArchiveService);
jobDataMap.put(ArchiveServiceApi.class.getName(), this);
JobDetail archiveJob = JobBuilder.newJob(ArchiveScheduledJob.class)
.usingJobData(jobDataMap)
.withIdentity(ARCHIVE_JOB_NAME, ARCHIVE_GROUP_NAME).build();
Trigger archiveTrigger = TriggerBuilder
.newTrigger()
.startAt(DateUtils.addMinutes(new Date(), ARCHIVE_STARTUP_DELAY_IN_MIN))
.withSchedule(
SimpleScheduleBuilder.simpleSchedule().withIntervalInHours(24).repeatForever()
.withMisfireHandlingInstructionFireNow()).build();
scheduler.scheduleJob(archiveJob, archiveTrigger);
log.info("Archiving job check is scheduled to run every 24 hours. Starting at: "
+ archiveTrigger.getStartTime());
} else if (!reponse.getDto().getAutoSchedule()) {
// If archiving is disabled, delete the job if it exists
if (scheduler.deleteJob(new JobKey(ArchiveScheduledJob.ARCHIVE_JOB_NAME, ARCHIVE_GROUP_NAME))) {
log.info("Archiving job Deleted");
}
}
} catch (Exception e) {
log.error("Scheduler fail to start/stop Archiving job", e);
this.alertGenerator.processSystemFailureEvent(SystemFailureType.ARCHIVE_FAILURE,
new LockObjectReference(1L, "Archive Settings", ObjectType.ARCHIVE),
"Failure during archive schedule configuration " + e.getMessage());
}
}
示例9: deleteNotification
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Delete a scheduled emails.
*
* @throws JSONException
*/
public ActionForward deleteNotification(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, SchedulerException, JSONException {
String inputTriggerName = WebUtil.readStrParam(request, "triggerName");
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID, true);
Integer userId = getCurrentUser().getUserID();
boolean isLessonNotifications = (lessonId != null);
Integer organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID, true);
IMonitoringService monitoringService = MonitoringServiceProxy
.getMonitoringService(getServlet().getServletContext());
getUserManagementService();
Scheduler scheduler = getScheduler();
JSONObject jsonObject = new JSONObject();
String error = null;
try {
// if this method throws an Exception, there will be no deleteNotification=true in the JSON reply
if (isLessonNotifications) {
if (!getSecurityService().isLessonMonitor(lessonId, userId, "show scheduled lesson email notifications",
false)) {
error = "Unable to delete notification: the user is not a monitor in the lesson";
}
} else {
if (!getSecurityService().isGroupMonitor(organisationId, userId,
"show scheduled course course email notifications", false)) {
error = "Unable to delete notification: the user is not a monitor in the organisation";
}
}
if (error == null) {
Set<TriggerKey> triggerKeys = scheduler
.getTriggerKeys(GroupMatcher.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
for (TriggerKey triggerKey : triggerKeys) {
String triggerName = triggerKey.getName();
if (triggerName.equals(inputTriggerName)) {
Trigger trigger = scheduler.getTrigger(triggerKey);
JobKey jobKey = trigger.getJobKey();
JobDetail jobDetail = scheduler.getJobDetail(trigger.getJobKey());
JobDataMap jobDataMap = jobDetail.getJobDataMap();
getAuditService().log(MonitoringConstants.MONITORING_MODULE_NAME,
"Deleting unsent scheduled notification " + jobKey + " "
+ jobDataMap.getString("emailBody"));
scheduler.deleteJob(jobKey);
}
}
}
} catch (Exception e) {
String[] msg = new String[1];
msg[0] = e.getMessage();
error = monitoringService.getMessageService().getMessage("error.system.error", msg);
}
jsonObject.put("deleteNotification", error == null ? "true" : error);
response.setContentType("application/json;charset=utf-8");
response.getWriter().print(jsonObject);
return null;
}
示例10: updateEmailProgressDate
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* Add or remove a date for the email progress
*/
public ActionForward updateEmailProgressDate(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, JSONException {
Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
if (!getSecurityService().isLessonMonitor(lessonId, getCurrentUser().getUserID(), "get class members", false)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a monitor in the lesson");
return null;
}
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
// as we are using ms since UTC 0 calculated on the client, this will be correctly set up as server date
// and does not need changing (assuming the user's LAMS timezone matches the user's computer timezone).
long dateId = WebUtil.readLongParam(request, "id");
Date newDate = new Date(dateId);
boolean add = WebUtil.readBooleanParam(request, "add");
// calculate scheduleDate
String scheduledTriggerName = getTriggerName(lessonId, newDate);
JSONObject dateJSON = null;
try {
Scheduler scheduler = getScheduler();
Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(GroupMatcher
.triggerGroupEquals(Scheduler.DEFAULT_GROUP));
Trigger trigger = null;
for (TriggerKey triggerKey : triggerKeys) {
if (scheduledTriggerName.equals(triggerKey.getName())) {
trigger = scheduler.getTrigger(triggerKey);
break;
}
}
if (add) {
if (trigger == null) {
String desc = new StringBuilder("Send progress email. Lesson ")
.append(lessonId).append(" on ").append(newDate).toString();
// build job detail based on the bean class
JobDetail EmailProgressMessageJob = JobBuilder.newJob(EmailProgressMessageJob.class)
.withIdentity(getJobName(lessonId, newDate))
.withDescription(desc)
.usingJobData(AttributeNames.PARAM_LESSON_ID, lessonId).build();
// create customized triggers
Trigger startLessonTrigger = TriggerBuilder.newTrigger().withIdentity(scheduledTriggerName)
.startAt(newDate).build();
// start the scheduling job
scheduler.scheduleJob(EmailProgressMessageJob, startLessonTrigger);
dateJSON = createDateJSON(request.getLocale(), user, newDate, "added");
} else {
dateJSON = createDateJSON(request.getLocale(), user, newDate, "none");
}
} else if (!add) {
if (trigger != null) {
// remove trigger
scheduler.deleteJob(trigger.getJobKey());
dateJSON = createDateJSON(request.getLocale(), user, null, "deleted");
} else {
dateJSON = createDateJSON(request.getLocale(), user, null, "none");
}
}
} catch (SchedulerException e) {
LamsDispatchAction.log.error("Error occurred at " + "[EmailProgressAction]- fail to email scheduling", e);
}
if (dateJSON != null) {
response.setContentType("application/json;charset=utf-8");
response.getWriter().write(dateJSON.toString());
}
return null;
}
示例11: removeSchedule
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 关闭一个调度任务
*
* @param name
* @throws SchedulerException
*/
public boolean removeSchedule(String name) throws SchedulerException {
Scheduler scheduler = SF.getScheduler();
JobKey key = new JobKey(name, Scheduler.DEFAULT_GROUP);
return scheduler.deleteJob(key);
}
示例12: deleteJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 删除一个job
*
* @param scheduleJob
* @throws SchedulerException
*/
public void deleteJob(ScheduleJob scheduleJob) throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
JobKey jobKey = JobKey.jobKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());
scheduler.deleteJob(jobKey);
}