Package org.quartz

Examples of org.quartz.Trigger


*/
  @Override
  public void start() {
    try {
      JobDetail jobDetail = super.getJobDetail();
      Trigger trigger = getSimpleTrigger(timeUnit, (int) interval);
      scheduler = StdSchedulerFactory.getDefaultScheduler();
      scheduler.scheduleJob(jobDetail, trigger);
      scheduler.start();
    } catch (SchedulerException se) {
      logger.error("Error occurred while starting the relative scheduler : " + se.getMessage(), se);
View Full Code Here


      simpleScheduleBuilder.withIntervalInHours(timeInterval * 24).repeatForever();
      break;
    default:
      throw new RuntimeException("The " + RelativeOutputSchedule.class.getSimpleName() + " cannot handle a time unit of " + timeUnit); //default 1 sec
    }
    Trigger simpleTrigger = TriggerBuilder.newTrigger().withSchedule(simpleScheduleBuilder).build();
    return simpleTrigger;
  }
View Full Code Here

        camel1.start();

        QuartzComponent component = (QuartzComponent) camel1.getComponent("quartz2");
        Scheduler scheduler = component.getScheduler();
        TriggerKey triggerKey = TriggerKey.triggerKey("myTimerName", "myGroup");
        Trigger trigger = scheduler.getTrigger(triggerKey);
        Assert.assertNotNull(trigger);

        camel1.stopRoute("route-1");

        Trigger.TriggerState triggerState = component.getScheduler().getTriggerState(triggerKey);
View Full Code Here

    private void addJobInScheduler() throws Exception {
        // Add or use existing trigger to/from scheduler
        Scheduler scheduler = getComponent().getScheduler();
        JobDetail jobDetail;
        Trigger trigger = scheduler.getTrigger(triggerKey);
        if (trigger == null) {
            jobDetail = createJobDetail();
            trigger = createTrigger(jobDetail);

            QuartzHelper.updateJobDataMap(getCamelContext(), jobDetail, getEndpointUri());

            // Schedule it now. Remember that scheduler might not be started it, but we can schedule now.
            Date nextFireDate = scheduler.scheduleJob(jobDetail, trigger);
            if (LOG.isInfoEnabled()) {
                LOG.info("Job {} (triggerType={}, jobClass={}) is scheduled. Next fire date is {}",
                         new Object[] {trigger.getKey(), trigger.getClass().getSimpleName(),
                                       jobDetail.getJobClass().getSimpleName(), nextFireDate});
            }
        } else {
            ensureNoDupTriggerKey();
        }
View Full Code Here

            }
        }
    }

    private Trigger createTrigger(JobDetail jobDetail) throws Exception {
        Trigger result;
        Date startTime = new Date();
        if (getComponent().getScheduler().isStarted()) {
            startTime = new Date(System.currentTimeMillis() + triggerStartDelay);
        }
        if (cron != null) {
View Full Code Here

        CamelContext camelContext = (CamelContext) schedulerContext.get(QuartzConstants.QUARTZ_CAMEL_CONTEXT + "-" + camelContextName);
        if (camelContext == null) {
            throw new JobExecutionException("No CamelContext could be found with name: " + camelContextName);
        }

        Trigger trigger = context.getTrigger();
        QuartzEndpoint endpoint = lookupQuartzEndpoint(camelContext, endpointUri, trigger);
        if (endpoint == null) {
            throw new JobExecutionException("No QuartzEndpoint could be found with endpointUri: " + endpointUri);
        }
        endpoint.onJobExecute(context);
View Full Code Here


            JobDetail job = newJob(com.google.code.ftspc.lector.CheckDateForPath.class).
                    withIdentity("jobForCheckDateForPath", "Lector").build();

            Trigger trigger = newTrigger().withIdentity("triggerForCheckDateForPath", "Lector").
                    withSchedule(simpleSchedule().withIntervalInHours(1).
                    repeatForever()).startNow().build();

            Vars.sched.scheduleJob(job, trigger);
        } catch (Exception ex) {
View Full Code Here

        Assert.assertEquals(triggerKey, Iterators.getOnlyElement(triggerKeys.iterator()));

        JobDetail jobDetail = scheduler.getJobDetail(jobKey);
        Assert.assertNotNull(jobDetail);

        Trigger trigger = scheduler.getTrigger(triggerKey);
        Assert.assertNotNull(trigger);
        Assert.assertNotNull(trigger.getScheduleBuilder());

        Thread.sleep(DEFAULT_SCHEDULE_PAUSE_MS);

        Assert.assertEquals(1, queue.size());
    }
View Full Code Here

*/
public class QuartzEndpointConfigureTest extends ContextTestSupport {

    public void testConfigureGroupAndName() throws Exception {
        QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz://myGroup/myName?trigger.repeatCount=3");
        Trigger trigger = endpoint.getTrigger();
        assertEquals("getName()", "myName", trigger.getName());
        assertEquals("getGroup()", "myGroup", trigger.getGroup());

        SimpleTrigger simpleTrigger = assertIsInstanceOf(SimpleTrigger.class, trigger);
        assertEquals("getRepeatCount()", 3, simpleTrigger.getRepeatCount());
    }
View Full Code Here

        assertEquals("getRepeatCount()", 3, simpleTrigger.getRepeatCount());
    }

    public void testConfigureName() throws Exception {
        QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz://myName");
        Trigger trigger = endpoint.getTrigger();
        assertEquals("getName()", "myName", trigger.getName());
        assertEquals("getGroup()", "Camel", trigger.getGroup());
    }
View Full Code Here

TOP

Related Classes of org.quartz.Trigger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.