Jan 14 2009

Using Eclipse Jobs API

Published by at 3:30 am under Eclipse,IT,Java

Eclipse platform offers great API for managing long running operations in the background. Besides the API for starting, stopping and monitoring progress of the Job – there is also standard UI for managing all those operations. I’m going to present sample usage of Jobs API in you own plug-in/application.

Creating and scheduling Job may look like this:

 TrainJob job = new TrainJob(TRAIN_JOB_NAME + file.getName(), classifier);
 job.schedule(); // start as soon as possible

Sample of custom Job:

package pl.edu.agh.caracal.classifier.popup.jobs;
import static org.eclipse.core.runtime.Status.OK_STATUS;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.Job;
import pl.edu.agh.caracal.classifier.ext.classifiers.AbstractClassifier;
 * Class for execution of training of a classifier
 * @since 1.0
public class TrainJob extends Job {
 private AbstractClassifier classifier;
  * Public constructor TrainJob
  * @param name Train job name
  * @param classifier Classifier to be trained
 public TrainJob(String name, AbstractClassifier classifier) {
 	this.classifier = classifier;
 protected IStatus run(IProgressMonitor monitor) {
 	// Long running operation - in this case classifier training
       // ...
       return OK_STATUS;

Standard GUI for presenting Job progress:

Jobs API View

3 responses so far

3 Responses to “Using Eclipse Jobs API”

  1. marioModelon 14 Jan 2009 at 9:17 am

    I have waited so long for an update to this wonderful blog… but after 4 months of waiting, I can honestly say it was worth the effort. Radek, I wanna give birth to your children:)

  2. sahaon 10 May 2010 at 10:49 am

    Pirated for the Eclipse Rich RCP application project

  3. TRXon 20 Oct 2011 at 2:57 am

    Get some useful tips for my RCP,

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.