Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>Trap some user-driven event, like updating a text value, for example a cron-string to schedule a job</li> <li>Locate and unschedule/delete the old job and trigger.</li> <li><p>Schedule the job again, using the new trigger.</p> <pre><code>public static &lt;T&gt; T scheduleCronJob(Class&lt;T&gt; clazz, String cronString, String uid){ try{ if(cronString == null){ throw new CronStringConfigurationException(); } String jobGroupName = "cronJobsGroup"; String jobName = "cronJob" + uid; String triggerGroupName = "cronTriggers"; String triggerName = "triggerFor" + uid; JobDetail jobDetail = new JobDetail(jobName, jobGroupName, clazz); CronTrigger trigger = new CronTrigger( triggerName, triggerGroupName, jobName, jobGroupName, cronString); JobDataMap jobDataMap = new JobDataMap(); jobDetail.setJobDataMap(jobDataMap); getScheduler().scheduleJob(jobDetail, trigger); } catch(Exception e){ // print error message, throw stack trace } return null; } public static void reloadCronJob(Class clazz, String cronString, String uid) throws SystemException, ParseException, SchedulerException, CronStringConfigurationException, PortalException{ // locate the job String jobGroupName = "cronJobs"; String jobName = "jobFor" + uid; if(cronString == null){ throw new CronStringConfigurationException(); } JobDetail jobDetail = null; Class&lt;?&gt; jobClass = null; // remove the old job/trigger if it exists try{ jobDetail = scheduler.getJobDetail(jobName, jobGroupName); if(jobDetail != null){ jobClass = jobDetail.getJobClass(); } scheduler.deleteJob(jobName, jobGroupName); } catch(Exception e){ e.printStackTrace(); } if(jobClass == null){ jobClass = clazz; } // create a new trigger scheduleCronJob(jobClass, expandoColumnName, uid); System.out.println("(re)scheduled job " + jobName + " using new cron string " + cronString); } </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload