Package org.quartz

Examples of org.quartz.Trigger


         if (obj != null)
            jobDetail.getJobDataMap().put(ORIGINAL_ENGINE_GLOBAL, obj);
         else
            throw new XmlBlasterException(global, ErrorCode.INTERNAL, "SchedulerPlugin.doInit", "Could not find the ServerScope");
         String triggerName = name;
         Trigger trigger = null;
        
         if (data.getMonth() > -1)
            throw new XmlBlasterException(global, ErrorCode.USER_CONFIGURATION, "SchedulerPlugin.doInit", "Yearly Events are not implemented");

         int dayOfMonth = data.getDayOfMonth();
         int hour = data.getHour();
         int min = data.getMin();
         if (dayOfMonth > -1) { // monthly trigger
            if (hour < 0)
               throw new XmlBlasterException(this.global, ErrorCode.USER_CONFIGURATION, "SchedulerPlugin.doInit", "On monthly triggers the hour must be specified");
            if (min < 0)
               throw new XmlBlasterException(this.global, ErrorCode.USER_CONFIGURATION, "SchedulerPlugin.doInit", "On monthly triggers the min must be specified");
            trigger = TriggerUtils.makeMonthlyTrigger(triggerName, dayOfMonth, hour, min);
            trigger.setStartTime(new Date())// start now
         }
         else {
            int dayOfWeek = data.getDayOfWeek();
            if (dayOfWeek > -1) {
               if (hour < 0)
                  throw new XmlBlasterException(this.global, ErrorCode.USER_CONFIGURATION, "SchedulerPlugin.doInit", "On weekly triggers the hour must be specified");
               if (min < 0)
                  throw new XmlBlasterException(this.global, ErrorCode.USER_CONFIGURATION, "SchedulerPlugin.doInit", "On weekly triggers the min must be specified");
               trigger = TriggerUtils.makeWeeklyTrigger(triggerName, dayOfWeek+1, hour, min);
               trigger.setStartTime(new Date())// start now
            }
            else {
               if (hour > -1) {
                  if (min < 0)
                     throw new XmlBlasterException(this.global, ErrorCode.USER_CONFIGURATION, "SchedulerPlugin.doInit", "On daily triggers the min must be specified");
                  trigger = TriggerUtils.makeDailyTrigger(triggerName, hour, min);
                  trigger.setStartTime(new Date())// start now
               }
               else {
                  if (min > -1) {
                     trigger = TriggerUtils.makeHourlyTrigger(1);
                     trigger.setName(triggerName);
                     Date startTime = TriggerUtils.getNextGivenMinuteDate(new Date(), min);
                     trigger.setStartTime(startTime);
                  }
                  else {
                     throw new XmlBlasterException(global, ErrorCode.USER_CONFIGURATION, "SchedulerPlugin.doInit", "No time has been specified in the configuration");
                  }
               }
View Full Code Here


                    "The createTimer(expiration, info) method cannot be called within the operation state '" + operationState
                            + "'.");
        }

        // Create the trigger that won't repeat
        Trigger trigger = new SimpleTrigger(getTriggerName(), getTriggerGroupName(), expiration);

        // Get timer
        return internalTimer(trigger, info);
    }
View Full Code Here

            throw new IllegalStateException("The createTimer(initialExpiration, intervalDuration, info) "
                    + "method cannot be called within the operation state '" + operationState + "'.");
        }

        // Create the trigger (repeat indefinitely)
        Trigger trigger = new SimpleTrigger(getTriggerName(), getTriggerGroupName(), initialExpiration, null,
                REPEAT_INDEFINITELY, intervalDuration);

        // Get timer
        return internalTimer(trigger, info);
    }
View Full Code Here

     
      System.err.println("captureScreenStart");
     
      JobDetail jobDetail = new JobDetail(ConnectionBean.quartzScreenJobName, Scheduler.DEFAULT_GROUP, ScreenJob.class);
     
      Trigger trigger = TriggerUtils.makeSecondlyTrigger(ConnectionBean.intervallSeconds);
      trigger.setStartTime(new Date());
      trigger.setName("myTrigger");
     
      sched.scheduleJob(jobDetail, trigger);
     
      startButton.setEnabled(false);
      stopButton.setEnabled(true);
View Full Code Here

        int repeatCount = taskDescription.getCount();
        long repeatInterval = taskDescription.getInterval();
        Date startTime = taskDescription.getStartTime();
        Date endTime = taskDescription.getEndTime();

        Trigger trigger;
        if (cron == null || "".equals(cron)) {
            if (repeatCount >= 0) {
                trigger = TriggerUtils.makeImmediateTrigger(repeatCount - 1, repeatInterval);
            } else {
                trigger = TriggerUtils.makeImmediateTrigger(SimpleTrigger.REPEAT_INDEFINITELY,
                        repeatInterval);
            }

        } else {
            CronTrigger cronTrigger = new CronTrigger();
            try {
                cronTrigger.setCronExpression(cron);
                trigger = cronTrigger;
            } catch (ParseException e) {
                throw new SynapseTaskException("Error setting cron expression : " +
                        e.getMessage() + cron, log);
            }
        }

        if (trigger == null) {
            throw new SynapseTaskException("Trigger is null for the Task description : " +
                    taskDescription, log);
        }

        if (startTime != null) {
            trigger.setStartTime(startTime);
        }
        if (endTime != null) {
            trigger.setEndTime(endTime);
        }
        // give the trigger a random name
        trigger.setName(name + "-trigger-" + String.valueOf(RANDOM.nextLong()));
        String group = taskDescription.getGroup();
        if (group != null && !"".equals(group)) {
            trigger.setGroup(group);
        } else {
            trigger.setGroup(TaskDescription.DEFAULT_GROUP);
        }
        trigger.setVolatility(taskDescription.isVolatility());
        return trigger;
    }
View Full Code Here

            reportTO.addExecution(getReportExecTO(reportExec));
        }

        String triggerName = JobInstanceLoader.getTriggerName(JobInstanceLoader.getJobName(report));

        Trigger trigger;
        try {
            trigger = scheduler.getScheduler().getTrigger(new TriggerKey(triggerName, Scheduler.DEFAULT_GROUP));
        } catch (SchedulerException e) {
            LOG.warn("While trying to get to " + triggerName, e);
            trigger = null;
        }

        if (trigger != null) {
            reportTO.setLastExec(trigger.getPreviousFireTime());
            reportTO.setNextExec(trigger.getNextFireTime());
        }

        return reportTO;
    }
View Full Code Here

    }

    private void setExecTime(final SchedTaskTO taskTO, final Task task) {
        String triggerName = JobInstanceLoader.getTriggerName(JobInstanceLoader.getJobName(task));

        Trigger trigger = null;
        try {
            trigger = scheduler.getScheduler().getTrigger(new TriggerKey(triggerName, Scheduler.DEFAULT_GROUP));
        } catch (SchedulerException e) {
            LOG.warn("While trying to get to " + triggerName, e);
        }

        if (trigger != null) {
            taskTO.setLastExec(trigger.getPreviousFireTime());
            taskTO.setNextExec(trigger.getNextFireTime());
        }
    }
View Full Code Here

                name = opts.name;
            } else {
                name = job.getClass().getName() + ':' + UUID.randomUUID();
            }

            final Trigger trigger = opts.trigger.withIdentity(name).build();

            // create the data map
            final JobDataMap jobDataMap = this.initDataMap(bundleId, name, job, opts);

            final JobDetail detail = this.createJobDetail(name, jobDataMap, opts.canRunConcurrently);
View Full Code Here

   * @see com.nokia.dempsy.output.OutputExecuter#start()
   */
  public void start() {
    try {
      JobDetail jobDetail = super.getJobDetail();
      Trigger trigger = getCronTrigger(cronExpression);
      scheduler = StdSchedulerFactory.getDefaultScheduler();
      scheduler.scheduleJob(jobDetail, trigger);
      scheduler.start();
    } catch (SchedulerException se) {
      logger.error("Error occurred while starting the cron scheduler : " + se.getMessage(), se);
View Full Code Here

   * @param cronExpression the cron expression
   * @return the cron trigger
   */
  private Trigger getCronTrigger(String cronExpression) {
    CronScheduleBuilder cronScheduleBuilder = null;
    Trigger cronTrigger = null;
    try {
      cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
      cronScheduleBuilder.withMisfireHandlingInstructionFireAndProceed();
      TriggerBuilder<Trigger> cronTtriggerBuilder = TriggerBuilder.newTrigger();
      cronTtriggerBuilder.withSchedule(cronScheduleBuilder);
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.