org.quartz.Job类的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(315)

本文整理了Java中org.quartz.Job类的一些代码示例,展示了Job类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job类的具体详情如下:
包路径:org.quartz.Job
类名称:Job

Job介绍

[英]The interface to be implemented by classes which represent a 'job' to be performed.

Instances of Job must have a public no-argument constructor.

JobDataMap provides a mechanism for 'instance member data' that may be required by some implementations of this interface.
[中]由表示要执行的“作业”的类实现的接口。
Job的实例必须具有public无参数构造函数。
JobDataMap为此接口的某些实现可能需要的“实例成员数据”提供了一种机制。

代码示例

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
  public void execute(QuartzJobContext quartzJobContext, Job job) throws Throwable {

    JobDataMap jobDataMap = JobDataMapSupport.newJobDataMap(quartzJobContext.getJobDataMap());

    // 用lts的覆盖
    Map<String, String> map = job.getExtParams();
    if (CollectionUtils.isNotEmpty(map)) {
      for (Map.Entry<String, String> entry : map.entrySet()) {
        jobDataMap.put(entry.getKey(), entry.getValue());
      }
    }

    JobExecutionContext jobExecutionContext = new JobExecutionContextImpl(jobDataMap);
    quartzJob.execute(jobExecutionContext);
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
  public void execute(QuartzJobContext quartzJobContext, Job job) throws Throwable {

    JobDataMap jobDataMap = JobDataMapSupport.newJobDataMap(quartzJobContext.getJobDataMap());

    // 用lts的覆盖
    Map<String, String> map = job.getExtParams();
    if (CollectionUtils.isNotEmpty(map)) {
      for (Map.Entry<String, String> entry : map.entrySet()) {
        jobDataMap.put(entry.getKey(), entry.getValue());
      }
    }

    JobExecutionContext jobExecutionContext = new JobExecutionContextImpl(jobDataMap);
    quartzJob.execute(jobExecutionContext);
  }
}

代码示例来源:origin: quartz-scheduler/quartz

job.execute(jec);
  endTime = System.currentTimeMillis();
} catch (JobExecutionException jee) {

代码示例来源:origin: quartz-scheduler/quartz

job.execute(jec);
  endTime = System.currentTimeMillis();
} catch (JobExecutionException jee) {

代码示例来源:origin: fang-yan-peng/cronner

public void executeJob() throws JobExecutionException {
  if(job != null){
    job.execute(null);
  }
}

代码示例来源:origin: fang-yan-peng/cronner

@Override
  public void run() {
    try {
      job.execute(null);
    } catch (JobExecutionException e) {
      log.error("Trigger job with dependency fail: ",e);
    }
  }
});

代码示例来源:origin: com.manydesigns/portofino-quartz

@Override
  public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
    job.execute(jobExecutionContext);
    try {
      //In a different class to make the database module optional at runtime
      SessionCleaner.closeSessions(servletContext);
    } catch (NoClassDefFoundError e) {
      logger.debug("Database module not available, not closing sessions", e);
    }
  }
};

代码示例来源:origin: sakaiproject/sakai

public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
 String beanId = jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
 Job job = (Job) ComponentManager.get(beanId);
 if (job instanceof StatefulJob) {
   log.warn("Non-stateful wrapper used with stateful job: "+ beanId+
   " You probably wanted to use SpringStatefulJobBeanWrapper for this job.");
 }
 job.execute(jobExecutionContext);
}

代码示例来源:origin: sakaiproject/sakai

public void execute(JobExecutionContext jobExecutionContext) throws 
  JobExecutionException {
    String beanId = 
      jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
    Job job = (Job) ComponentManager.get(beanId);
    job.execute(jobExecutionContext);
  }
}

代码示例来源:origin: com.atlassian.scheduler/atlassian-scheduler-quartz1

@Override
  public void execute(final JobExecutionContext context) throws JobExecutionException {
    service.preJob();
    final Thread thd = Thread.currentThread();
    final ClassLoader originalClassLoader = thd.getContextClassLoader();
    try {
      thd.setContextClassLoader(delegate.getClass().getClassLoader());
      delegate.execute(context);
    } finally {
      thd.setContextClassLoader(originalClassLoader);
      service.postJob();
    }
  }
}

代码示例来源:origin: org.sakaiproject.scheduler/scheduler-component-shared

public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
 String beanId = jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
 Job job = (Job) ComponentManager.get(beanId);
 if (job instanceof StatefulJob) {
   log.warn("Non-stateful wrapper used with stateful job: "+ beanId+
   " You probably wanted to use SpringStatefulJobBeanWrapper for this job.");
 }
 job.execute(jobExecutionContext);
}

代码示例来源:origin: org.sakaiproject.scheduler/scheduler-component-shared

public void execute(JobExecutionContext jobExecutionContext) throws 
  JobExecutionException {
    String beanId = 
      jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
    Job job = (Job) ComponentManager.get(beanId);
    job.execute(jobExecutionContext);
  }
}

代码示例来源:origin: ManyDesigns/Portofino

@Override
public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException {
  final Job job = super.newJob(bundle, scheduler);
  applicationContext.getAutowireCapableBeanFactory().autowireBean(job);
  return jobExecutionContext -> {
    job.execute(jobExecutionContext);
    try {
      //In a different class to make the database module optional at runtime
      SessionCleaner.closeSessions(applicationContext);
    } catch (NoClassDefFoundError e) {
      logger.debug("Database module not available, not closing sessions", e);
    }
  };
}

代码示例来源:origin: org.apache.geronimo.ext.openejb/openejb-core

public void execute(JobExecutionContext execution) throws JobExecutionException {
    JobDataMap jobDataMap = execution.getJobDetail().getJobDataMap();
    Data data = Data.class.cast(jobDataMap.get(Data.class.getName()));
    Job job = data.job;
    MessageEndpoint endpoint = (MessageEndpoint) job;
    try {
      Method method = Job.class.getMethod("execute", JobExecutionContext.class);
      endpoint.beforeDelivery(method);
      job.execute(execution);
    } catch (NoSuchMethodException e) {
      throw new IllegalStateException(e);
    } catch (ResourceException e) {
      throw new JobExecutionException(e);
    } finally {
      try {
        endpoint.afterDelivery();
      } catch (ResourceException e) {
        throw new JobExecutionException(e);
      }
    }
  }
}

代码示例来源:origin: com.github.ltsopensource/lts-spring

@Override
  public void execute(QuartzJobContext quartzJobContext, Job job) throws Throwable {

    JobDataMap jobDataMap = JobDataMapSupport.newJobDataMap(quartzJobContext.getJobDataMap());

    // 用lts的覆盖
    Map<String, String> map = job.getExtParams();
    if (CollectionUtils.isNotEmpty(map)) {
      for (Map.Entry<String, String> entry : map.entrySet()) {
        jobDataMap.put(entry.getKey(), entry.getValue());
      }
    }

    JobExecutionContext jobExecutionContext = new JobExecutionContextImpl(jobDataMap);
    quartzJob.execute(jobExecutionContext);
  }
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-connector

job.execute(jobExecutionContext);

代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine

@Override
public void executeJob(final String jobIdentifier) throws RepositoryException {
  try {
    final RepositoryJobDetail jobDetail = (RepositoryJobDetail) scheduler.getJobDetail(new JobKey(jobIdentifier));
    final Job job = jobDetail.getJobClass().newInstance();
    job.execute(new JobExecutionContextImpl(scheduler, jobDetail));
  } catch (SchedulerException | InstantiationException | IllegalAccessException e) {
    throw new RepositoryException(e);
  }
}

代码示例来源:origin: pentaho/pentaho-platform

if ( getBlockoutManager().shouldFireNow() || isBlockoutAction( jobExecutionContext ) ) { // We should always let the blockouts fire //$NON-NLS-1$
 makeAuditRecord( 0, messageType, jobExecutionContext );
 createUnderlyingJob().execute( jobExecutionContext );
 end = System.currentTimeMillis();
 messageType = jobRestarted ? MessageTypes.RECREATED_INSTANCE_END : MessageTypes.INSTANCE_END;
  "Got Exception retrieving the Blockout Manager for job '" + jobExecutionContext.getJobDetail().getName()
    + "'. Executing the underlying job anyway", e );
createUnderlyingJob().execute( jobExecutionContext );
end = System.currentTimeMillis();
messageType = jobRestarted ? MessageTypes.RECREATED_INSTANCE_END : MessageTypes.INSTANCE_END;

代码示例来源:origin: org.mule.transports/mule-transport-quartz

((Job)tempJob).execute(jobExecutionContext);

代码示例来源:origin: quartz/quartz-all

job.execute(jec);
  endTime = System.currentTimeMillis();
} catch (JobExecutionException jee) {

相关文章

微信公众号

最新文章

更多

Job类方法