R
- the request type associated to the job@InstantiationStrategy(value=PER_LOOKUP) public abstract class AbstractJob<R extends Request,S extends JobStatus> extends Object implements Job
Job
implementations.Modifier and Type | Field and Description |
---|---|
protected ComponentManager |
componentManager
Component manager.
|
protected ContextStoreManager |
contextStore |
protected Condition |
finishedCondition
Condition to wait for finished state.
|
protected boolean |
initExecutionContext |
protected JobContext |
jobContext
Used to set the current context.
|
protected ReentrantLock |
lock
Main lock guarding all access.
|
protected org.slf4j.Logger |
logger
The logger to log.
|
protected org.xwiki.logging.LoggerManager |
loggerManager
Used to isolate job related log.
|
protected org.xwiki.observation.ObservationManager |
observationManager
Used to send extensions installation and upgrade related events.
|
protected JobProgressManager |
progressManager |
protected R |
request
The job request.
|
protected S |
status |
protected JobStatusStore |
store
Used to store the results of the jobs execution.
|
Constructor and Description |
---|
AbstractJob() |
Modifier and Type | Method and Description |
---|---|
protected R |
castRequest(Request request)
Should be overridden if R is not Request.
|
protected S |
createNewStatus(R request)
Create a new standard
JobStatus . |
R |
getRequest() |
S |
getStatus() |
void |
initialize(Request request) |
protected void |
jobFinished(Throwable error)
Called when the job is done.
|
protected void |
jobStarting()
Called when the job is starting.
|
void |
join()
Causes the current thread to wait until this job has FINSHED state.
|
boolean |
join(long time,
TimeUnit unit)
Causes the current thread to wait until this job has FINSHED state.
|
void |
run() |
protected void |
runInContext() |
protected abstract void |
runInternal()
Should be implemented by
Job implementations. |
void |
start(Request request)
Deprecated.
|
String |
toString() |
@Inject protected ComponentManager componentManager
@Inject protected org.xwiki.observation.ObservationManager observationManager
@Inject protected org.xwiki.logging.LoggerManager loggerManager
@Inject protected ContextStoreManager contextStore
@Inject protected JobStatusStore store
@Inject protected org.slf4j.Logger logger
@Inject protected JobContext jobContext
@Inject protected JobProgressManager progressManager
protected S extends JobStatus status
getStatus()
protected final ReentrantLock lock
protected final Condition finishedCondition
protected boolean initExecutionContext
public R getRequest()
getRequest
in interface Job
public S getStatus()
public void initialize(Request request)
initialize
in interface Job
request
- configure the jobprotected void runInContext()
protected void jobStarting()
protected void jobFinished(Throwable error)
error
- the exception throw during execution of the jobprotected R castRequest(Request request)
request
- the requestprotected S createNewStatus(R request)
request
- contains information related to the job to executeprotected abstract void runInternal() throws Exception
Job
implementations.Exception
- errors during job executionpublic void join() throws InterruptedException
Job
join
in interface Job
InterruptedException
- if any thread has interrupted the current thread. The interrupted status of
the current thread is cleared when this exception is thrown.public boolean join(long time, TimeUnit unit) throws InterruptedException
Job
join
in interface Job
time
- the maximum time to waitunit
- the time unit of the time
argumentfalse
if the waiting time detectably elapsed before return from the method, else true
InterruptedException
- if the current thread is interrupted (and interruption of thread suspension is
supported)@Deprecated public void start(Request request)
Copyright © 2004–2021 XWiki. All rights reserved.