Extensions Wiki » Extensions » Job Module

Job Module

Last modified by Thomas Mortagne on 2013/02/19 10:16
cogA set of APIs to easily communicate with an asynchronous task
TypeJAR
Developed by

XWiki Development Team

LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Enterprise, XWiki Enterprise Manager

Compatibility

Since 4.0 Milestone 1

Description

The goal of this module is to make easier to allow two ways communication with a task executed in a background thread.

Minimal job provide:

  • progress information
  • live log
  • Java bean based question/answer system

and can be extended as long as the client of the API know the extended interface.

Use an existing job

The common way to use a job is by going trough org.xwiki.job.JobManager.

Request jobRequest = new DefaultRequest();

// Indicate an id to allow you to access the status of this unique task
jobRequest.setId("taskid");
// Allow the job to ask questions during its executing
jobRequest.setInteractive(true);
// Put some custom configuration
jobRequest.setProperty("some custom jobtype related parameter", "value");

// Execute a task using Job with role hint "jobtype" and wait for it to be finished
jobManager.executeJob("jobtype", request)

// Add the task in the queue of tasks to execute and return right away
jobManager.addJob("jobtype", request)

Create a job

To register a new job that anyone can then use in JobManager you need to register a component with role org.xwiki.job.Job and a role hint to differentiate it from other jobs and allow users to target it.

Tags:
Created by Thomas Mortagne on 2012/04/03 11:14

Download XWiki