Defining a job

Define your job to be performed. For example, the job DumbJob is defined as follows:

package org.exoplatform.samples.scheduler.jobs;

import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
 * DumbJob for executing a defined dumb job.
public class DumbJob implements Job {
   * The logger
  private static final Log LOG = ExoLogger.getLogger(DumbJob.class);
   * The job of the DumbJob will be done by executing this method.
   * @param context
   * @throws JobExecutionException
  public void execute(JobExecutionContext context) throws JobExecutionException {
    LOG.info("DumbJob is executing...");

All jobs are required to implement the method execute from org.quartz.Job interface. This method will be called whenever a job is performed. With DumbJob, you just use logging to see that it will work. By looking at the terminal, you will see the the log message: "DumbJob is executing..."

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus