Пример #1
0
 private JobDetail createJobDetail(final ScheduledJobDetail scheduledJobDetail) throws Exception {
   final MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant();
   final ClassMethodNamesPair jobDetails =
       CronMethodParser.findTargetMethodDetails(scheduledJobDetail.getJobName());
   if (jobDetails == null) {
     throw new IllegalArgumentException(
         "Code has no @CronTarget with this job name (@see JobName); seems like DB/code are not in line: "
             + scheduledJobDetail.getJobName());
   }
   final Object targetObject = getBeanObject(Class.forName(jobDetails.className));
   final MethodInvokingJobDetailFactoryBean jobDetailFactoryBean =
       new MethodInvokingJobDetailFactoryBean();
   jobDetailFactoryBean.setName(scheduledJobDetail.getJobName() + "JobDetail" + tenant.getId());
   jobDetailFactoryBean.setTargetObject(targetObject);
   jobDetailFactoryBean.setTargetMethod(jobDetails.methodName);
   jobDetailFactoryBean.setGroup(scheduledJobDetail.getGroupName());
   jobDetailFactoryBean.setConcurrent(false);
   jobDetailFactoryBean.afterPropertiesSet();
   return jobDetailFactoryBean.getObject();
 }
Пример #2
0
 private Trigger createTrigger(
     final ScheduledJobDetail scheduledJobDetails, final JobDetail jobDetail) {
   try {
     final MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant();
     final CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
     cronTriggerFactoryBean.setName(scheduledJobDetails.getJobName() + "Trigger" + tenant.getId());
     cronTriggerFactoryBean.setJobDetail(jobDetail);
     final JobDataMap jobDataMap = new JobDataMap();
     jobDataMap.put(SchedulerServiceConstants.TENANT_IDENTIFIER, tenant.getTenantIdentifier());
     cronTriggerFactoryBean.setJobDataMap(jobDataMap);
     final TimeZone timeZone = TimeZone.getTimeZone(tenant.getTimezoneId());
     cronTriggerFactoryBean.setTimeZone(timeZone);
     cronTriggerFactoryBean.setGroup(scheduledJobDetails.getGroupName());
     cronTriggerFactoryBean.setCronExpression(scheduledJobDetails.getCronExpression());
     cronTriggerFactoryBean.setPriority(scheduledJobDetails.getTaskPriority());
     cronTriggerFactoryBean.afterPropertiesSet();
     return cronTriggerFactoryBean.getObject();
   } catch (ParseException e) {
     throw new RuntimeException(e);
   }
 }