@Test public void testJobScheduling() throws Exception { Assert.assertNotNull(dynamicQuartzSchedulerManager); testJobRunCount = 0; dynamicQuartzSchedulerManager.addJob("test-job", "test-group", new TestJob(), "* * * * * ?"); while (true) { synchronized(runCountLockObject) { if (testJobRunCount >= 2) { break; } } Thread.sleep(500); } Assert.assertEquals(2, testJobRunCount); }
public void addJob(String jobName, String groupName, Object job, String cronExpression) throws Exception { logger.debug("Adding job " + jobName + " (" + groupName + ")"); MethodInvokingJobDetailFactoryBean jdfb = new MethodInvokingJobDetailFactoryBean(); jdfb.setTargetObject(job); jdfb.setTargetMethod("run"); jdfb.setName(jobName); jdfb.setGroup(groupName); jdfb.setConcurrent(false); jdfb.afterPropertiesSet(); Trigger trigger = newTrigger() .withIdentity(jobName + "-trigger", groupName + "-trigger") .withSchedule(cronSchedule(cronExpression)) .forJob(jobName, groupName) .build(); schedulerFactory.getScheduler().scheduleJob((JobDetail)jdfb.getObject(), trigger); jobNames.add(jobName); jobGroupNames.put(jobName, groupName); logger.trace("Job " + jobName + " scheduled"); }
DynamicQuartzSchedulerManager { public void addJob(String jobName, String groupName, Object job, String cronExpression) throws Exception { logger.debug("Adding job " + jobName + " (" + groupName + ")"); MethodInvokingJobDetailFactoryBean jdfb = new MethodInvokingJobDetailFactoryBean(); jdfb.setTargetObject(job); jdfb.setTargetMethod("run"); jdfb.setName(jobName); jdfb.setGroup(groupName); jdfb.setConcurrent(false); jdfb.afterPropertiesSet(); Trigger trigger = newTrigger() .withIdentity(jobName + "-trigger", groupName + "-trigger") .withSchedule(cronSchedule(cronExpression)) .forJob(jobName, groupName) .build(); schedulerFactory.getScheduler().scheduleJob((JobDetail)jdfb.getObject(), trigger); jobNames.add(jobName); jobGroupNames.put(jobName, groupName); logger.trace("Job " + jobName + " scheduled"); } }
DynamicQuartzSchedulerManager { public void addJob(String jobName, String groupName, Object job, String cronExpression) throws Exception { logger.debug("Adding job " + jobName + " (" + groupName + ")"); MethodInvokingJobDetailFactoryBean jdfb = new MethodInvokingJobDetailFactoryBean(); jdfb.setTargetObject(job); jdfb.setTargetMethod("run"); jdfb.setName(jobName); jdfb.setGroup(groupName); jdfb.setConcurrent(false); jdfb.afterPropertiesSet(); Trigger trigger = newTrigger() .withIdentity(jobName + "-trigger", groupName + "-trigger") .withSchedule(cronSchedule(cronExpression)) .forJob(jobName, groupName) .build(); schedulerFactory.getScheduler().scheduleJob((JobDetail)jdfb.getObject(), trigger); jobNames.add(jobName); jobGroupNames.put(jobName, groupName); logger.trace("Job " + jobName + " scheduled"); }  }
DynamicQuartzSchedulerManager { public void addJob(String jobName, String groupName, Object job, String cronExpression) throws Exception { logger.debug("Adding job " + jobName + " (" + groupName + ")"); MethodInvokingJobDetailFactoryBean jdfb = new MethodInvokingJobDetailFactoryBean(); jdfb.setTargetObject(job); jdfb.setTargetMethod("run"); jdfb.setName(jobName); jdfb.setGroup(groupName); jdfb.setConcurrent(false); jdfb.afterPropertiesSet(); Trigger trigger = newTrigger() .withIdentity(jobName + "-trigger", groupName + "-trigger") .withSchedule(cronSchedule(cronExpression)) .forJob(jobName, groupName) .build(); schedulerFactory.getScheduler().scheduleJob((JobDetail)jdfb.getObject(), trigger); jobNames.add(jobName); jobGroupNames.put(jobName, groupName); logger.trace("Job " + jobName + " scheduled"); }  void start(); void stop(); void addJob(String jobName, String groupName, Object job, String cronExpression); void runJob(String jobName, String groupName, Object job); void deleteJob(String jobName); void deleteAlljobs(); }
DynamicQuartzSchedulerManager { public void addJob(String jobName, String groupName, Object job, String cronExpression) throws Exception { logger.debug("Adding job " + jobName + " (" + groupName + ")"); MethodInvokingJobDetailFactoryBean jdfb = new MethodInvokingJobDetailFactoryBean(); jdfb.setTargetObject(job); jdfb.setTargetMethod("run"); jdfb.setName(jobName); jdfb.setGroup(groupName); jdfb.setConcurrent(false); jdfb.afterPropertiesSet(); Trigger trigger = newTrigger() .withIdentity(jobName + "-trigger", groupName + "-trigger") .withSchedule(cronSchedule(cronExpression)) .forJob(jobName, groupName) .build(); schedulerFactory.getScheduler().scheduleJob((JobDetail)jdfb.getObject(), trigger); jobNames.add(jobName); jobGroupNames.put(jobName, groupName); logger.trace("Job " + jobName + " scheduled"); }  void start(); void stop(); void addJob(String jobName, String groupName, Object job, String cronExpression); void runJob(String jobName, String groupName, Object job); void deleteJob(String jobName); void deleteAlljobs();  }