Java Code Examples for org.quartz.Job#execute()

The following examples show how to use org.quartz.Job#execute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockScheduler.java    From smarthome with Eclipse Public License 2.0 13 votes vote down vote up
/**
 * "Run" all of the jobs in the scheduler.
 *
 * NB this is a mock class. We ignore the time that the jobs are
 * actually scheduled for, and just run them all.
 *
 * @throws JobExecutionException
 * @throws IllegalAccessException
 * @throws InstantiationException
 *
 */
public void run() throws JobExecutionException, InstantiationException, IllegalAccessException {
    for (Entry<Trigger, JobExecutionContext> entry : jobs.entrySet()) {
        JobExecutionContext context = entry.getValue();
        try {
            currentlyExecutingJobs.add(context);
            Job job = context.getJobDetail().getJobClass().newInstance();
            job.execute(context);
        } finally {
            currentlyExecutingJobs.remove(context);
            jobs.remove(entry.getKey());
            Trigger newTrigger = rescheduledJobs.remove(context.getTrigger().getKey());
            if (newTrigger != null) {
                jobs.put(newTrigger, context);
            }
        }
    }
}
 
Example 2
Source File: CommonJobBean.java    From dubai with MIT License 6 votes vote down vote up
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
    StopWatch stopWatch = new LoggingStopWatch();

    ApplicationContext applicationContext = getApplicationContext(jobExecutionContext);
    String realJobBeanName = getRealJobBeanName(jobExecutionContext);
    Job realJob = (Job) applicationContext.getBean(realJobBeanName);

    try {
        realJob.execute(jobExecutionContext);
    } catch (Exception e) {
        logger.error(String.format("Error happened when execute job, realJobBeanName: %s, jobDataMap:[%s]", realJobBeanName, buildJobDataMap(jobExecutionContext)), e);
    }

    stopWatch.stop(String.format("Job executed, realJobBeanName: %s, jobDataMap:[%s]", realJobBeanName, buildJobDataMap(jobExecutionContext)));
}
 
Example 3
Source File: ExecuteBIDocumentJob.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
	logger.debug("IN");

	Job job = new XExecuteBIDocumentJob();
	job.execute(jobExecutionContext);
	logger.debug("OUT");
}
 
Example 4
Source File: SpringJobBeanWrapper.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
   String beanId = jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
   Job job = (Job) applicationContext.getBean(beanId);
   if (job instanceof StatefulJob) {
      log.warn("Non-stateful wrapper used with stateful job: {}, use SpringStatefulJobBeanWrapper", beanId);
   }
   job.execute(jobExecutionContext);
}
 
Example 5
Source File: SpringJobBeanWrapper.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
   String beanId = jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
   Job job = (Job) applicationContext.getBean(beanId);
   if (job instanceof StatefulJob) {
      log.warn("Non-stateful wrapper used with stateful job: {}, use SpringStatefulJobBeanWrapper", beanId);
   }
   job.execute(jobExecutionContext);
}
 
Example 6
Source File: SpringStatefulJobBeanWrapper.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
	String beanId = jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
	Job job = (Job) applicationContext.getBean(beanId);
	job.execute(jobExecutionContext);
}
 
Example 7
Source File: SpringStatefulJobBeanWrapper.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
	String beanId = jobExecutionContext.getJobDetail().getJobDataMap().getString(SPRING_BEAN_NAME);
	Job job = (Job) applicationContext.getBean(beanId);
	job.execute(jobExecutionContext);
}
 
Example 8
Source File: JobAdapter.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(Job job, JobExecutionContext context) throws JobExecutionException
{
    job.execute(context);
}