org.xwiki.job.internal
Class DefaultJobManager

java.lang.Object
  extended by org.xwiki.job.internal.DefaultJobManager
All Implemented Interfaces:
Runnable, Initializable, JobManager

@Component
@Singleton
public class DefaultJobManager
extends Object
implements JobManager, Runnable, Initializable

Default implementation of JobManager.

Since:
4.0M1

Constructor Summary
DefaultJobManager()
           
 
Method Summary
 Job addJob(String jobType, Request request)
          Add a new job in the queue of jobs to execute.
 Job executeJob(String jobType, Request request)
          Start a new job with the provided identifier and wait until its finished.
 Job getCurrentJob()
           
 JobStatus getJobStatus(List<String> id)
          Return job status corresponding to the provided id from the current executed job or stored history.
 JobStatus getJobStatus(String id)
          Return job status corresponding to the provided id from the current executed job or stored history.
 void initialize()
          Method called by the Component Manager when the component is created for the first time (i.e.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultJobManager

public DefaultJobManager()
Method Detail

initialize

public void initialize()
                throws InitializationException
Description copied from interface: Initializable
Method called by the Component Manager when the component is created for the first time (i.e. when it's looked up for the first time or if the component is specified as being loaded on startup). If the component instantiation strategy is singleton then this method is called only once during the lifecycle of the Component Manager. Otherwise the component is created at each lookup and thus this method is called at each lookup too.

Specified by:
initialize in interface Initializable
Throws:
InitializationException - if an error happens during a component's initialization

run

public void run()
Specified by:
run in interface Runnable

getCurrentJob

public Job getCurrentJob()
Specified by:
getCurrentJob in interface JobManager
Returns:
the job currently running or the latest job, null if there is no job

executeJob

public Job executeJob(String jobType,
                      Request request)
               throws JobException
Description copied from interface: JobManager
Start a new job with the provided identifier and wait until its finished.

Specified by:
executeJob in interface JobManager
Parameters:
jobType - the role hint of the job component
request - the request
Returns:
the created job
Throws:
JobException - error when creating the job

addJob

public Job addJob(String jobType,
                  Request request)
           throws JobException
Description copied from interface: JobManager
Add a new job in the queue of jobs to execute.

Specified by:
addJob in interface JobManager
Parameters:
jobType - the role hint of the job component
request - the request
Returns:
the created job
Throws:
JobException - error when creating the job

getJobStatus

public JobStatus getJobStatus(String id)
Description copied from interface: JobManager
Return job status corresponding to the provided id from the current executed job or stored history.

Specified by:
getJobStatus in interface JobManager
Parameters:
id - the id of the job
Returns:
the job status corresponding to the provided job id, null if none can be found

getJobStatus

public JobStatus getJobStatus(List<String> id)
Description copied from interface: JobManager
Return job status corresponding to the provided id from the current executed job or stored history.

Specified by:
getJobStatus in interface JobManager
Parameters:
id - the id of the job
Returns:
the job status corresponding to the provided job id, null if none can be found