Package org.quartz

Examples of org.quartz.Scheduler


        } else {
            throw new EJBException("The timer component found is not a Quartz Timer Component ('" + timerComponent + "').");
        }

        // Get Scheduler on the quartz component
        Scheduler scheduler = quartzComponent.getScheduler();

        // Get detail
        JobDetail jobDetail = null;
        try {
            jobDetail = scheduler.getJobDetail(jobName, groupName);
        } catch (SchedulerException e) {
            throw new EJBException("Cannot get the jobDetail for the jobName '" + jobName + "'.", e);
        }

        // Cast to correct object
        EasyBeansJobDetail easyBeansJobDetail = null;
        if (jobDetail instanceof EasyBeansJobDetail) {
            easyBeansJobDetail = (EasyBeansJobDetail) jobDetail;
        } else {
            throw new EJBException("JobDetail found for the job named '" + jobName + "' is not an EasyBeansJobDetail object");
        }

        // Get triggers
        Trigger[] triggers = null;
        try {
            triggers = scheduler.getTriggersOfJob(jobName, groupName);
        } catch (SchedulerException e) {
            throw new EJBException("Cannot get triggers for the job named '" + jobName + "'.", e);
        }

        // Should be only once trigger per job
View Full Code Here


      CronTrigger trigger = new CronTrigger();
      trigger.setName(jobName);
      trigger.setGroup(LOG_DISPLAYER_GROUP);
      trigger.setCronExpression("* * * * * ?");
      // Schedule job now
      Scheduler scheduler = (Scheduler) CoreSpringFactory.getBean("schedulerFactoryBean");
      scheduler.addJobListener(this);
      scheduler.scheduleJob(jobDetail, trigger);
    } catch (ParseException e) {
      logError("Can not parse log viewer cron expression", e);
    } catch (SchedulerException e) {
      logError("Problem when creating log viewer scheduler", e);
    }
View Full Code Here

   * @see org.olat.core.gui.control.DefaultController#doDispose()
   */
  @Override
  protected void doDispose() {
    if (logViewerVC != null) { // don't clean up twice
      Scheduler scheduler = (Scheduler) CoreSpringFactory.getBean("schedulerFactoryBean");
      // remove scheduler job first
      try {
        scheduler.deleteJob(jobName, LOG_DISPLAYER_GROUP);
        scheduler.removeJobListener(jobName);
      } catch (SchedulerException e) {
        logError("Can not delete log viewer job", e);
      }
      // remove logger appender and release StringWriter
      log4JLogger.removeAppender(writerAppender);
View Full Code Here

      startLink = LinkFactory.createButtonSmall("logviewer.link.start", logViewerVC, this);
      // remove logger appender
      log4JLogger.removeAppender(writerAppender);
      // pause log update trigger job
      try {
        Scheduler scheduler = (Scheduler) CoreSpringFactory.getBean("schedulerFactoryBean");
        scheduler.pauseJob(jobName, LOG_DISPLAYER_GROUP);
      } catch (SchedulerException e) {
        logError("Can not pause log viewer job", e);
      }
    }
    if (source == startLink) {
      // update viewable links
      logViewerVC.remove(startLink);
      updateLink = LinkFactory.createButtonSmall("logviewer.link.update", logViewerVC, this);
      stopLink = LinkFactory.createButtonSmall("logviewer.link.stop", logViewerVC, this);
      // re-add appender to logger
      log4JLogger.addAppender(writerAppender);
      // resume trigger job
      try {
        Scheduler scheduler = (Scheduler) CoreSpringFactory.getBean("schedulerFactoryBean");
        scheduler.resumeJob(jobName, LOG_DISPLAYER_GROUP);
      } catch (SchedulerException e) {
        logError("Can not resume log viewer job", e);
      }
    }   
  }
View Full Code Here

    String cronExpression = "";
    if (CoreSpringFactory.containsBean("schedulerFactoryBean")) {
      log_.info("refreshUIState: schedulerFactoryBean found");
      Object schedulerFactoryBean = CoreSpringFactory.getBean("schedulerFactoryBean");
      if (schedulerFactoryBean!=null && schedulerFactoryBean instanceof Scheduler) {
        Scheduler schedulerBean = (Scheduler) schedulerFactoryBean;
        int triggerState;
        try {
          triggerState = schedulerBean.getTriggerState("updateStatisticsTrigger", null/*trigger group*/);
          enabled = (triggerState!=Trigger.STATE_NONE) && (triggerState!=Trigger.STATE_ERROR);
          log_.info("refreshUIState: updateStatisticsTrigger state was "+triggerState+", enabled now: "+enabled);
        } catch (SchedulerException e) {
          log_.warn("refreshUIState: Got a SchedulerException while asking for the updateStatisticsTrigger's state", e);
        }
View Full Code Here

    // remove properties
    if (persitedProperties != null) {
      persitedProperties.destroy();
    }
    // Stop registration job
    Scheduler scheduler = (Scheduler) CoreSpringFactory.getBean("schedulerFactoryBean");
    try {
      scheduler.deleteJob(SCHEDULER_NAME, Scheduler.DEFAULT_GROUP);
    } catch (SchedulerException e) {
      logError("Could not shut down job::" + SCHEDULER_NAME, e);
    }
  }
View Full Code Here

    //
   
    // Don't run in jUnit mode
    if (Settings.isJUnitTest()) return;
    // create a crontrigger inside because cron expression is random generated -> this can not be done by config? REVIEW:gs:
    Scheduler scheduler = (Scheduler) CoreSpringFactory.getBean("schedulerFactoryBean");
    String cronExpression = "ERROR";
    try {
      // Create job with cron trigger configuration
      JobDetail jobDetail = new JobDetail(SCHEDULER_NAME, Scheduler.DEFAULT_GROUP, SystemRegistrationJob.class);
      CronTrigger trigger = new CronTrigger();
      trigger.setName("system_registration_trigger");
      cronExpression = persitedProperties.getStringPropertyValue(CONF_KEY_REGISTRATION_CRON, true);
      if (!CronExpression.isValidExpression(cronExpression)) {
        cronExpression = createCronTriggerExpression();
        persitedProperties.setStringPropertyDefault(CONF_KEY_REGISTRATION_CRON, cronExpression);
      }
      // Use this cron expression for debugging, tries to send data every minute
      //trigger.setCronExpression("0 * * * * ?");
      trigger.setCronExpression(cronExpression);
      // Schedule job now
      scheduler.scheduleJob(jobDetail, trigger);
    } catch (ParseException e) {

      logError("Illegal cron expression for scheduling translation status generator", e);
    } catch (SchedulerException e) {
      logError("Can not start translation status generator scheduler", e);
View Full Code Here

   * Internal helper to initialize the cron syncer job
   */
  private void initCronSyncJob() {
    //FIXME: move this to spring and add a delay otherwise the job may accesses the database and the database it not yet ready, see examples in spring with jobs
    // Use scheduler from spring config
    Scheduler scheduler = (Scheduler) CoreSpringFactory.getBean("schedulerFactoryBean");
    try {
      // Create job with cron trigger configuration
      JobDetail jobDetail = new JobDetail("LDAP_Cron_Syncer_Job", Scheduler.DEFAULT_GROUP, LDAPUserSynchronizerJob.class);
      CronTrigger trigger = new CronTrigger();
      trigger.setName("LDAP_Cron_Syncer_Trigger");
      trigger.setCronExpression(ldapSyncCronSyncExpression);
      // Schedule job now
      scheduler.scheduleJob(jobDetail, trigger);
      log.info("LDAP cron syncer is enabled with expression::" + ldapSyncCronSyncExpression);
    } catch (ParseException e) {
      setLdapSyncCronSync(false);
      log
          .error(
View Full Code Here

     * @see org.apache.felix.webconsole.ConfigurationPrinter#printConfiguration(java.io.PrintWriter)
     */
    public void printConfiguration(PrintWriter pw) {
        pw.println(HEADLINE);
        pw.println();
        final Scheduler s = this.scheduler.getScheduler();
        if ( s != null ) {
            pw.println("Status : active");
            try {
                pw.print  ("Name   : ");
                pw.println(s.getSchedulerName());
                pw.print  ("Id     : ");
                pw.println(s.getSchedulerInstanceId());
                final List<String> groups = s.getJobGroupNames();
                for(final String group : groups) {
                    final Set<JobKey> keys = s.getJobKeys(GroupMatcher.jobGroupEquals(group));
                    for(final JobKey key : keys) {
                        final JobDetail detail = s.getJobDetail(key);
                        final String jobName = (String) detail.getJobDataMap().get(QuartzScheduler.DATA_MAP_NAME);
                        final Object job = detail.getJobDataMap().get(QuartzScheduler.DATA_MAP_OBJECT);
                        // only print jobs started through the sling scheduler
                        if ( jobName != null && job != null ) {
                            pw.print("Job : ");
                            pw.print(detail.getJobDataMap().get(QuartzScheduler.DATA_MAP_NAME));
                            if ( detail.getDescription() != null && detail.getDescription().length() > 0 ) {
                                pw.print(" (");
                                pw.print(detail.getDescription());
                                pw.print(")");
                            }
                            pw.print(", class: ");
                            pw.print(job.getClass().getName());
                            pw.print(", concurrent: ");
                            pw.print(!detail.isConcurrentExectionDisallowed());
                            final String[] runOn = (String[])detail.getJobDataMap().get(QuartzScheduler.DATA_MAP_RUN_ON);
                            if ( runOn != null ) {
                                pw.print(", runOn: ");
                                pw.print(Arrays.toString(runOn));
                            }
                            final Long bundleId = (Long)detail.getJobDataMap().get(QuartzScheduler.DATA_MAP_BUNDLE_ID);
                            if ( bundleId != null ) {
                                pw.print(", bundleId: ");
                                pw.print(String.valueOf(bundleId));
                            }
                            pw.println();
                            for(final Trigger trigger : s.getTriggersOfJob(key)) {
                                pw.print("Trigger : ");
                                pw.print(trigger);
                                pw.println();
                            }
                            pw.println();
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

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.