Пример #1
0
 @PostConstruct
 public void loadAllJobs() {
   final List<MifosPlatformTenant> allTenants = this.tenantDetailsService.findAllTenants();
   for (final MifosPlatformTenant tenant : allTenants) {
     ThreadLocalContextUtil.setTenant(tenant);
     final List<ScheduledJobDetail> scheduledJobDetails =
         this.schedularWritePlatformService.retrieveAllJobs();
     for (final ScheduledJobDetail jobDetails : scheduledJobDetails) {
       scheduleJob(jobDetails);
       jobDetails.updateTriggerMisfired(false);
       this.schedularWritePlatformService.saveOrUpdate(jobDetails);
     }
     final SchedulerDetail schedulerDetail =
         this.schedularWritePlatformService.retriveSchedulerDetail();
     if (schedulerDetail.isResetSchedulerOnBootup()) {
       schedulerDetail.updateSuspendedState(false);
       this.schedularWritePlatformService.updateSchedulerDetail(schedulerDetail);
     }
   }
 }
Пример #2
0
 @Override
 public void startScheduler() {
   final SchedulerDetail schedulerDetail =
       this.schedularWritePlatformService.retriveSchedulerDetail();
   if (schedulerDetail.isSuspended()) {
     schedulerDetail.updateSuspendedState(false);
     this.schedularWritePlatformService.updateSchedulerDetail(schedulerDetail);
     if (schedulerDetail.isExecuteInstructionForMisfiredJobs()) {
       final List<ScheduledJobDetail> scheduledJobDetails =
           this.schedularWritePlatformService.retrieveAllJobs();
       for (final ScheduledJobDetail jobDetail : scheduledJobDetails) {
         if (jobDetail.isTriggerMisfired()) {
           if (jobDetail.isActiveSchedular()) {
             executeJob(jobDetail, SchedulerServiceConstants.TRIGGER_TYPE_CRON);
           }
           final String schedulerName = getSchedulerName(jobDetail);
           final Scheduler scheduler = this.schedulers.get(schedulerName);
           if (scheduler != null) {
             final String key = jobDetail.getJobKey();
             final JobKey jobKey = constructJobKey(key);
             try {
               final List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
               for (final Trigger trigger : triggers) {
                 if (trigger.getNextFireTime() != null
                     && trigger.getNextFireTime().after(jobDetail.getNextRunTime())) {
                   jobDetail.updateNextRunTime(trigger.getNextFireTime());
                 }
               }
             } catch (final SchedulerException e) {
               logger.error(e.getMessage(), e);
             }
           }
           jobDetail.updateTriggerMisfired(false);
           this.schedularWritePlatformService.saveOrUpdate(jobDetail);
         }
       }
     }
   }
 }