/** * Starts a Job matching the the given Job Name found in jobs.xml * * @param jobName */ public static void startJob(String jobName, Map<String, Object> params) { try { JobDataMap jobDataMap = new JobDataMap(); for (String key : params.keySet()) { // logger.debug("key= " + key); // logger.debug("value= " + pParams.get(key)); jobDataMap.put(key, params.get(key)); } getScheduler().triggerJob(jobName, jobDataMap); } catch (SchedulerException e) { logger.error("ERROR STARTING JOB!!!", e); } }
/** * Retrieve the identified <code>String</code> value from the <code>JobDataMap</code>. * * @throws ClassCastException if the identified object is not a String. */ public String getString(String key) { Object obj = get(key); try { return (String) obj; } catch (Exception e) { throw new ClassCastException("Identified object is not a String."); } }
@Override public Object clone() { JobDetailImpl copy; try { copy = (JobDetailImpl) super.clone(); if (jobDataMap != null) { copy.jobDataMap = jobDataMap.shallowCopy(); } } catch (CloneNotSupportedException ex) { throw new IncompatibleClassChangeError("Not Cloneable."); } return copy; }
@Override public JobDataMap getJobDataMap() { if (jobDataMap == null) { jobDataMap = new JobDataMap(); } return jobDataMap; }
/** Create a JobExcecutionContext with the given context data. */ public JobExecutionContextImpl(Scheduler scheduler, TriggerFiredBundle firedBundle, Job job) { this.scheduler = scheduler; this.trigger = firedBundle.getTrigger(); this.calendar = firedBundle.getCalendar(); this.jobDetail = firedBundle.getJobDetail(); this.job = job; this.recovering = firedBundle.isRecovering(); this.fireTime = firedBundle.getFireTime(); this.scheduledFireTime = firedBundle.getScheduledFireTime(); this.prevFireTime = firedBundle.getPrevFireTime(); this.nextFireTime = firedBundle.getNextFireTime(); this.jobDataMap = new JobDataMap(); this.jobDataMap.putAll(jobDetail.getJobDataMap()); this.jobDataMap.putAll(trigger.getJobDataMap()); }
/** * Add all the mappings from the JobExecutionContext to the JobContext * * @param jobExecutionContext */ public void addQuartzContext(JobExecutionContext jobExecutionContext) { for (Object mapKey : jobExecutionContext.getMergedJobDataMap().keySet()) { // logger.debug("added key: " + (String) mapKey); // logger.debug("added value: " + (String) jobExecutionContext.getMergedJobDataMap().get(mapKey)); map.put((String) mapKey, jobExecutionContext.getMergedJobDataMap().get(mapKey)); } map.put(KEY_JOB_NAME, jobExecutionContext.getJobDetail().getName()); map.put(KEY_TRIGGER_NAME, (jobExecutionContext.getTrigger().getName())); if (jobExecutionContext.getTrigger() instanceof CronTrigger) { map.put(KEY_TRIGGER_CRON_EXPRESSION, ((CronTrigger) jobExecutionContext.getTrigger()).getCronExpression()); } }
@Override public String toString() { return "name: '" + getName() + "', Job Class: " + ((getJobClass() == null) ? null : getJobClass().getName()) + ", description: " + getDescription() + " isConcurrencyAllowed: " + isConcurrencyAllowed() + ", jobDataMap: " + ((jobDataMap == null) ? "empty" : Arrays.toString(jobDataMap.entrySet().toArray())); }
private void addToJobDataMap(JobDataMap jobDataMap, String[] stringEncodedMap) { for (int i = 0; i < stringEncodedMap.length; i++) { String[] keyValue = stringEncodedMap[i].split(SEPARATOR); if (keyValue == null || keyValue.length != 2) { logger.warn(stringEncodedMap[i] + " was not parsable!!! Skipping."); continue; } jobDataMap.put(keyValue[0].trim(), keyValue[1].trim()); } }
/** * Produce the <code>JobDetail</code> instance defined by this <code>JobBuilder</code>. * * @return the defined JobDetail. */ public JobDetail build() { JobDetailImpl job = new JobDetailImpl(); job.setJobClass(jobClass); job.setDescription(description); if (key == null) { key = UUID.randomUUID().toString(); } job.setName(key); job.setIsConcurrencyAllowed(isConcurrencyAllowed); if (!jobDataMap.isEmpty()) { job.setJobDataMap(jobDataMap); } return job; }
if (jobExecutionContext.getJobInstance() instanceof Job) { JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap(); String value = jobDataMap.getString(key); if (value != null & value.equalsIgnoreCase(pValue)) { ((Job) jobExecutionContext.getJobInstance()).interrupt();
@Override public JobDataMap getJobDataMap() { if (jobDataMap == null) { jobDataMap = new JobDataMap(); } return jobDataMap; }
/** * <p> * Create a JobExcecutionContext with the given context data. * </p> */ public JobExecutionContextImpl(Scheduler scheduler, TriggerFiredBundle firedBundle, Job job) { this.scheduler = scheduler; this.trigger = firedBundle.getTrigger(); this.calendar = firedBundle.getCalendar(); this.jobDetail = firedBundle.getJobDetail(); this.job = job; this.recovering = firedBundle.isRecovering(); this.fireTime = firedBundle.getFireTime(); this.scheduledFireTime = firedBundle.getScheduledFireTime(); this.prevFireTime = firedBundle.getPrevFireTime(); this.nextFireTime = firedBundle.getNextFireTime(); this.jobDataMap = new JobDataMap(); this.jobDataMap.putAll(jobDetail.getJobDataMap()); this.jobDataMap.putAll(trigger.getJobDataMap()); }
/** * Add all the mappings from the JobExecutionContext to the JobContext * * @param jobExecutionContext */ public void addQuartzContext(JobExecutionContext jobExecutionContext) { for (Object mapKey : jobExecutionContext.getMergedJobDataMap().keySet()) { // logger.debug("added key: " + (String) mapKey); // logger.debug("added value: " + (String) jobExecutionContext.getMergedJobDataMap().get(mapKey)); map.put((String) mapKey, jobExecutionContext.getMergedJobDataMap().get(mapKey)); } map.put(KEY_JOB_NAME, jobExecutionContext.getJobDetail().getName()); map.put(KEY_TRIGGER_NAME, (jobExecutionContext.getTrigger().getName())); if (jobExecutionContext.getTrigger() instanceof CronTrigger) { map.put(KEY_TRIGGER_CRON_EXPRESSION, ((CronTrigger) jobExecutionContext.getTrigger()).getCronExpression()); } }
@Override public String toString() { return "Trigger '" + getName() + "', triggerClass: " + getClass().getSimpleName() + ", jobName: " + getJobName() + ", jobDataMap: " + ((jobDataMap == null) ? "empty" : Arrays.toString(jobDataMap.entrySet().toArray())) + ", calendar: " + getCalendarName() + ", misfireInstruction: " + getMisfireInstruction() + ", priority: " + getPriority() + ", nextFireTime: " + getNextFireTime(); } }
private void addToJobDataMap(JobDataMap jobDataMap, String[] stringEncodedMap) { for (int i = 0; i < stringEncodedMap.length; i++) { String[] keyValue = stringEncodedMap[i].split(SEPARATOR); if (keyValue == null || keyValue.length != 2) { logger.warn(stringEncodedMap[i] + " was not parsable!!! Skipping."); continue; } jobDataMap.put(keyValue[0].trim(), keyValue[1].trim()); } }
/** * Produce the <code>JobDetail</code> instance defined by this <code>JobBuilder</code>. * * @return the defined JobDetail. */ public JobDetail build() { JobDetailImpl job = new JobDetailImpl(); job.setJobClass(jobClass); job.setDescription(description); if (key == null) { key = UUID.randomUUID().toString(); } job.setName(key); job.setIsConcurrencyAllowed(isConcurrencyAllowed); if (!jobDataMap.isEmpty()) { job.setJobDataMap(jobDataMap); } return job; }
if (jobExecutionContext.getJobInstance() instanceof Job) { JobDataMap jobDataMap = jobExecutionContext.getMergedJobDataMap(); String value = jobDataMap.getString(key); if (value != null & value.equalsIgnoreCase(pValue)) { ((Job) jobExecutionContext.getJobInstance()).interrupt();
/** * Starts a Job matching the the given Job Name found in jobs.xml * * @param jobName */ public static void startJob(String jobName, Map<String, Object> params) throws SundialSchedulerException { try { JobDataMap jobDataMap = new JobDataMap(); for (String key : params.keySet()) { // logger.debug("key= " + key); // logger.debug("value= " + pParams.get(key)); jobDataMap.put(key, params.get(key)); } getScheduler().triggerJob(jobName, jobDataMap); } catch (SchedulerException e) { throw new SundialSchedulerException("ERROR STARTING JOB!!!", e); } }
@Override public JobDataMap getJobDataMap() { if (jobDataMap == null) { jobDataMap = new JobDataMap(); } return jobDataMap; }
/** * <p> * Create a JobExcecutionContext with the given context data. * </p> */ public JobExecutionContextImpl(Scheduler scheduler, TriggerFiredBundle firedBundle, Job job) { this.scheduler = scheduler; this.trigger = firedBundle.getTrigger(); this.calendar = firedBundle.getCalendar(); this.jobDetail = firedBundle.getJobDetail(); this.job = job; this.recovering = firedBundle.isRecovering(); this.fireTime = firedBundle.getFireTime(); this.scheduledFireTime = firedBundle.getScheduledFireTime(); this.prevFireTime = firedBundle.getPrevFireTime(); this.nextFireTime = firedBundle.getNextFireTime(); this.jobDataMap = new JobDataMap(); this.jobDataMap.putAll(jobDetail.getJobDataMap()); this.jobDataMap.putAll(trigger.getJobDataMap()); }