Package org.quartz

Examples of org.quartz.Scheduler


   * @see #executeInternal
   */
  public final void execute(JobExecutionContext context) throws JobExecutionException {
    try {
      // Reflectively adapting to differences between Quartz 1.x and Quartz 2.0...
      Scheduler scheduler = (Scheduler) ReflectionUtils.invokeMethod(getSchedulerMethod, context);
      Map mergedJobDataMap = (Map) ReflectionUtils.invokeMethod(getMergedJobDataMapMethod, context);

      BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
      MutablePropertyValues pvs = new MutablePropertyValues();
      pvs.addPropertyValues(scheduler.getContext());
      pvs.addPropertyValues(mergedJobDataMap);
      bw.setPropertyValues(pvs, true);
    }
    catch (SchedulerException ex) {
      throw new JobExecutionException(ex);
View Full Code Here


  protected Scheduler findScheduler(String schedulerName) throws SchedulerException {
    if (this.beanFactory instanceof ListableBeanFactory) {
      ListableBeanFactory lbf = (ListableBeanFactory) this.beanFactory;
      String[] beanNames = lbf.getBeanNamesForType(Scheduler.class);
      for (String beanName : beanNames) {
        Scheduler schedulerBean = (Scheduler) lbf.getBean(beanName);
        if (schedulerName.equals(schedulerBean.getSchedulerName())) {
          return schedulerBean;
        }
      }
    }
    Scheduler schedulerInRepo = SchedulerRepository.getInstance().lookup(schedulerName);
    if (schedulerInRepo == null) {
      throw new IllegalStateException("No Scheduler named '" + schedulerName + "' found");
    }
    return schedulerInRepo;
  }
View Full Code Here

      currentThread.setContextClassLoader(this.resourceLoader.getClassLoader());
    }
    try {
      SchedulerRepository repository = SchedulerRepository.getInstance();
      synchronized (repository) {
        Scheduler existingScheduler = (schedulerName != null ? repository.lookup(schedulerName) : null);
        Scheduler newScheduler = schedulerFactory.getScheduler();
        if (newScheduler == existingScheduler) {
          throw new IllegalStateException("Active Scheduler of name '" + schedulerName + "' already registered " +
              "in Quartz SchedulerRepository. Cannot create a new Spring-managed Scheduler of the same name!");
        }
        if (!this.exposeSchedulerInRepository) {
          // Need to remove it in this case, since Quartz shares the Scheduler instance by default!
          SchedulerRepository.getInstance().remove(newScheduler.getSchedulerName());
        }
        return newScheduler;
      }
    }
    finally {
View Full Code Here

   * @see #executeInternal
   */
  public final void execute(JobExecutionContext context) throws JobExecutionException {
    try {
      // Reflectively adapting to differences between Quartz 1.x and Quartz 2.0...
      Scheduler scheduler = (Scheduler) ReflectionUtils.invokeMethod(getSchedulerMethod, context);
      Map mergedJobDataMap = (Map) ReflectionUtils.invokeMethod(getMergedJobDataMapMethod, context);

      BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
      MutablePropertyValues pvs = new MutablePropertyValues();
      pvs.addPropertyValues(scheduler.getContext());
      pvs.addPropertyValues(mergedJobDataMap);
      bw.setPropertyValues(pvs, true);
    }
    catch (SchedulerException ex) {
      throw new JobExecutionException(ex);
View Full Code Here

  protected Scheduler findScheduler(String schedulerName) throws SchedulerException {
    if (this.beanFactory instanceof ListableBeanFactory) {
      ListableBeanFactory lbf = (ListableBeanFactory) this.beanFactory;
      String[] beanNames = lbf.getBeanNamesForType(Scheduler.class);
      for (int i = 0; i < beanNames.length; i++) {
        Scheduler schedulerBean = (Scheduler) lbf.getBean(beanNames[i]);
        if (schedulerName.equals(schedulerBean.getSchedulerName())) {
          return schedulerBean;
        }
      }
    }
    Scheduler schedulerInRepo = SchedulerRepository.getInstance().lookup(schedulerName);
    if (schedulerInRepo == null) {
      throw new IllegalStateException("No Scheduler named '" + schedulerName + "' found");
    }
    return schedulerInRepo;
  }
View Full Code Here

        }
        return answer;
    }

    protected Scheduler createScheduler() throws SchedulerException {
        Scheduler scheduler = getFactory().getScheduler();
        // register current camel context to scheduler so we can look it up when jobs is being triggered
        scheduler.getContext().put(QuartzConstants.QUARTZ_CAMEL_CONTEXT + "-" + getCamelContext().getName(), getCamelContext());
        return scheduler;
    }
View Full Code Here

  protected Scheduler findScheduler(String schedulerName) throws SchedulerException {
    if (this.beanFactory instanceof ListableBeanFactory) {
      ListableBeanFactory lbf = (ListableBeanFactory) this.beanFactory;
      String[] beanNames = lbf.getBeanNamesForType(Scheduler.class);
      for (int i = 0; i < beanNames.length; i++) {
        Scheduler schedulerBean = (Scheduler) lbf.getBean(beanNames[i]);
        if (schedulerName.equals(schedulerBean.getSchedulerName())) {
          return schedulerBean;
        }
      }
    }
    Scheduler schedulerInRepo = SchedulerRepository.getInstance().lookup(schedulerName);
    if (schedulerInRepo == null) {
      throw new IllegalStateException("No Scheduler named '" + schedulerName + "' found");
    }
    return schedulerInRepo;
  }
View Full Code Here

      currentThread.setContextClassLoader(this.resourceLoader.getClassLoader());
    }
    try {
      SchedulerRepository repository = SchedulerRepository.getInstance();
      synchronized (repository) {
        Scheduler existingScheduler = (schedulerName != null ? repository.lookup(schedulerName) : null);
        Scheduler newScheduler = schedulerFactory.getScheduler();
        if (newScheduler == existingScheduler) {
          throw new IllegalStateException("Active Scheduler of name '" + schedulerName + "' already registered " +
              "in Quartz SchedulerRepository. Cannot create a new Spring-managed Scheduler of the same name!");
        }
        if (!this.exposeSchedulerInRepository) {
          // Need to explicitly remove it if not intended for exposure,
          // since Quartz shares the Scheduler instance by default!
          SchedulerRepository.getInstance().remove(newScheduler.getSchedulerName());
        }
        return newScheduler;
      }
    }
    finally {
View Full Code Here

    trigger1.setStartDelay(0);
    trigger1.setRepeatInterval(20);
    trigger1.afterPropertiesSet();

    MockControl schedulerControl = MockControl.createControl(Scheduler.class);
    final Scheduler scheduler = (Scheduler) schedulerControl.getMock();
    scheduler.getContext();
    schedulerControl.setReturnValue(new SchedulerContext());
    scheduler.getJobDetail("myJob0", Scheduler.DEFAULT_GROUP);
    schedulerControl.setReturnValue(null);
    scheduler.getJobDetail("myJob1", Scheduler.DEFAULT_GROUP);
    schedulerControl.setReturnValue(null);
    scheduler.getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP);
    schedulerControl.setReturnValue(null);
    scheduler.getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP);
    schedulerControl.setReturnValue(null);
    scheduler.addJob(jobDetail0, true);
    schedulerControl.setVoidCallable();
    scheduler.scheduleJob(trigger0);
    schedulerControl.setReturnValue(new Date());
    scheduler.addJob(jobDetail1, true);
    schedulerControl.setVoidCallable();
    scheduler.scheduleJob(trigger1);
    schedulerControl.setReturnValue(new Date());
    scheduler.start();
    schedulerControl.setVoidCallable();
    scheduler.shutdown(false);
    schedulerControl.setVoidCallable();
    schedulerControl.replay();

    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() {
      protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) {
View Full Code Here

    trigger1.setStartDelay(0);
    trigger1.setRepeatInterval(20);
    trigger1.afterPropertiesSet();

    MockControl schedulerControl = MockControl.createControl(Scheduler.class);
    final Scheduler scheduler = (Scheduler) schedulerControl.getMock();
    scheduler.getContext();
    schedulerControl.setReturnValue(new SchedulerContext());
    scheduler.getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP);
    schedulerControl.setReturnValue(null);
    scheduler.getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP);
    schedulerControl.setReturnValue(new SimpleTrigger());
    if (overwrite) {
      scheduler.addJob(jobDetail1, true);
      schedulerControl.setVoidCallable();
      scheduler.rescheduleJob("myTrigger1", Scheduler.DEFAULT_GROUP, trigger1);
      schedulerControl.setReturnValue(new Date());
    }
    else {
      scheduler.getJobDetail("myJob0", Scheduler.DEFAULT_GROUP);
      schedulerControl.setReturnValue(null);
    }
    scheduler.addJob(jobDetail0, true);
    schedulerControl.setVoidCallable();
    scheduler.scheduleJob(trigger0);
    schedulerControl.setReturnValue(new Date());
    scheduler.start();
    schedulerControl.setVoidCallable();
    scheduler.shutdown(false);
    schedulerControl.setVoidCallable();
    schedulerControl.replay();

    SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() {
      protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) {
View Full Code Here

TOP

Related Classes of org.quartz.Scheduler

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.