private static String buildJobName(am.projects.webserver.report.vo.Scheduler aScheduler) { return aScheduler.getApplicationName() + "/" + aScheduler.getServerName() + "/" + aScheduler.getAsName(); }
/** * schedule a job * * @param aScheduler scheduler to start * @throws SchedulerException */ public static void schedule(am.projects.webserver.report.vo.Scheduler aScheduler) throws SchedulerException { if (null == scheduler) return; JobDataMap dataMap = new JobDataMap(); dataMap.put(am.projects.webserver.report.vo.Scheduler.class.getSimpleName(), aScheduler); // define the job and tie it to our HelloJob class String jobName = buildJobName(aScheduler); String groupName = buildJobGroupName(aScheduler); JobKey jobKey = new JobKey(jobName, groupName); JobDetail job = newJob(MonitorJob.class).withIdentity(jobKey).usingJobData(dataMap).build(); TriggerKey triggerKey = new TriggerKey(jobName, groupName); Trigger trigger = newTrigger() .withIdentity(triggerKey) .startNow() .withSchedule( simpleSchedule() .withIntervalInMinutes(aScheduler.getRequestRepeatIntervalInMinutes()) .repeatForever()) .build(); scheduler.scheduleJob(job, trigger); }