Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A sample job has been provided below.

Code Block
package org.apache.syncope.core.scheduling;

import org.quartz.JobExecutionException;
import org.apache.syncope.core.persistence.beans.SchedTask;
import org.apache.syncope.core.persistence.beans.TaskExec;

/**
 * Simple scheduled task job.
 *
 * @see SchedTask
 */
public class DemoJob extends AbstractJob {

    @Override
    protected String doExecute(final boolean dryRun)
            throws JobExecutionException {

        if (!(task instanceof SchedTask)) {
            throw new JobExecutionException("Task " + taskId + " isn't a SchedTask");
        }
        final SchedTask schedTask = (SchedTask) this.task;

        LOG.info(
            "SampleJob {} running [SchedTask {}]", (dryRun ? "dry " : ""), schedTask.getId());

        return (dryRun ? "DRY " : "") + "RUNNING";
    }

    @Override
    protected boolean hasToBeRegistered(final TaskExec execution) {
        return true;
    }
}

...