Search in sources :

Example 11 with JobDetailImpl

use of org.quartz.impl.JobDetailImpl in project spring-framework by spring-projects.

the class MethodInvokingJobDetailFactoryBean method afterPropertiesSet.

@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() throws ClassNotFoundException, NoSuchMethodException {
    prepare();
    // Use specific name if given, else fall back to bean name.
    String name = (this.name != null ? this.name : this.beanName);
    // Consider the concurrent flag to choose between stateful and stateless job.
    Class<?> jobClass = (this.concurrent ? MethodInvokingJob.class : StatefulMethodInvokingJob.class);
    // Build JobDetail instance.
    JobDetailImpl jdi = new JobDetailImpl();
    jdi.setName(name);
    jdi.setGroup(this.group);
    jdi.setJobClass((Class) jobClass);
    jdi.setDurability(true);
    jdi.getJobDataMap().put("methodInvoker", this);
    this.jobDetail = jdi;
    postProcessJobDetail(this.jobDetail);
}
Also used : JobDetailImpl(org.quartz.impl.JobDetailImpl)

Example 12 with JobDetailImpl

use of org.quartz.impl.JobDetailImpl in project spring-framework by spring-projects.

the class QuartzSupportTests method schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored.

@Test
public void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws Exception {
    Assume.group(TestGroup.PERFORMANCE);
    DummyJob.param = 0;
    DummyJob.count = 0;
    JobDetailImpl jobDetail = new JobDetailImpl();
    jobDetail.setDurability(true);
    jobDetail.setJobClass(DummyJob.class);
    jobDetail.setName("myJob");
    jobDetail.getJobDataMap().put("para", "10");
    jobDetail.getJobDataMap().put("ignoredParam", "10");
    SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
    trigger.setName("myTrigger");
    trigger.setJobDetail(jobDetail);
    trigger.setStartDelay(1);
    trigger.setRepeatInterval(500);
    trigger.setRepeatCount(1);
    trigger.afterPropertiesSet();
    SchedulerFactoryBean bean = new SchedulerFactoryBean();
    SpringBeanJobFactory jobFactory = new SpringBeanJobFactory();
    jobFactory.setIgnoredUnknownProperties("ignoredParam");
    bean.setJobFactory(jobFactory);
    bean.setTriggers(trigger.getObject());
    bean.setJobDetails(jobDetail);
    bean.afterPropertiesSet();
    Thread.sleep(500);
    assertEquals(0, DummyJob.param);
    assertTrue(DummyJob.count == 0);
    bean.destroy();
}
Also used : JobDetailImpl(org.quartz.impl.JobDetailImpl) Test(org.junit.Test)

Example 13 with JobDetailImpl

use of org.quartz.impl.JobDetailImpl in project engine by craftercms.

the class FolderBasedScriptJobResolverTest method testResolveJobs.

@Test
public void testResolveJobs() throws Exception {
    List<JobContext> jobContexts = resolver.resolveJobs(siteContext);
    assertNotNull(jobContexts);
    assertEquals(1, jobContexts.size());
    JobDetailImpl jobDetail = (JobDetailImpl) jobContexts.get(0).getDetail();
    CronTrigger trigger = (CronTrigger) jobContexts.get(0).getTrigger();
    assertEquals(ScriptJob.class, jobDetail.getJobClass());
    assertEquals("/scripts/jobs/testJob.groovy", jobDetail.getJobDataMap().getString(ScriptJob.SCRIPT_URL_DATA_KEY));
    assertEquals(HOURLY_CRON_EXPRESSION, trigger.getCronExpression());
}
Also used : CronTrigger(org.quartz.CronTrigger) JobDetailImpl(org.quartz.impl.JobDetailImpl) JobContext(org.craftercms.engine.util.quartz.JobContext) Test(org.junit.Test)

Aggregations

JobDetailImpl (org.quartz.impl.JobDetailImpl)13 Test (org.junit.Test)9 JobDetail (org.quartz.JobDetail)3 ParseException (java.text.ParseException)2 JobContext (org.craftercms.engine.util.quartz.JobContext)2 RequisitionDef (org.opennms.netmgt.config.provisiond.RequisitionDef)2 CronTrigger (org.quartz.CronTrigger)2 SchedulerException (org.quartz.SchedulerException)2 CronTriggerImpl (org.quartz.impl.triggers.CronTriggerImpl)2 Calendar (java.util.Calendar)1 Report (org.opennms.netmgt.config.reportd.Report)1 Job (org.quartz.Job)1 JobExecutionContext (org.quartz.JobExecutionContext)1 Trigger (org.quartz.Trigger)1 TriggerListener (org.quartz.TriggerListener)1 SimpleTriggerImpl (org.quartz.impl.triggers.SimpleTriggerImpl)1