Search in sources :

Example 1 with SimpleTrigger

use of org.apache.openejb.quartz.SimpleTrigger in project tomee by apache.

the class JobBean method createJob.

@Override
public Date createJob() throws Exception {
    final QuartzResourceAdapter ra = (QuartzResourceAdapter) new InitialContext().lookup("java:openejb/Resource/QuartzResourceAdapter");
    final Scheduler s = ra.getScheduler();
    //Add a job type
    final JobDetail jd = JobBuilder.newJob(MyTestJob.class).withIdentity("job1", "group1").build();
    jd.getJobDataMap().put("MyJobKey", "MyJobValue");
    //Schedule my 'test' job to run now
    final SimpleTrigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger1", "group1").forJob(jd).withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(0).withIntervalInSeconds(0)).build();
    return s.scheduleJob(jd, trigger);
}
Also used : QuartzResourceAdapter(org.apache.openejb.resource.quartz.QuartzResourceAdapter) JobDetail(org.apache.openejb.quartz.JobDetail) Scheduler(org.apache.openejb.quartz.Scheduler) SimpleTrigger(org.apache.openejb.quartz.SimpleTrigger) InitialContext(javax.naming.InitialContext)

Aggregations

InitialContext (javax.naming.InitialContext)1 JobDetail (org.apache.openejb.quartz.JobDetail)1 Scheduler (org.apache.openejb.quartz.Scheduler)1 SimpleTrigger (org.apache.openejb.quartz.SimpleTrigger)1 QuartzResourceAdapter (org.apache.openejb.resource.quartz.QuartzResourceAdapter)1