|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread uws.job.JobThread
public class JobThread
An instance of this class is a thread dedicated to a job execution.
This thread is necessary associated with an AbstractJob
instance. Thus the execution of this thread (Thread.start()
)
mainly consists in calling the AbstractJob.jobWork()
method.
However its execution is possible only if the job phase is EXECUTING
. The job phase constraint (=EXECUTING) is
already checked so it is useless to check it again in AbstractJob.jobWork()
.
AbstractJob.jobWork()
) according to the execution conclusion:
AbstractJob.abort()
must be calledAbstractJob.error(ErrorSummary)
or AbstractJob.error(UWSException)
.In both cases the startTime and the endTime fields are already managed by AbstractJob
so it is useless to change them.
Just after the job work the job phase is set to COMPLETED
if no interruption has been detected,
ABORTED
otherwise.
AbstractJob.jobWork()
throws:
UWSException
: the method AbstractJob.error(UWSException)
is called.
Besides the exception is kept in the lastError
and is available thanks to the AbstractJob.getWorkError()
.InterruptedException
: the method AbstractJob.abort()
is called.
AbstractJob.start()
,
AbstractJob.jobWork()
,
AbstractJob.abort()
,
AbstractJob.error(ErrorSummary)
,
AbstractJob.error(UWSException)
,
AbstractJob.getWorkError()
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected boolean |
finished
Indicates whether the AbstractJob.jobWork() has been called and finished, or not. |
protected AbstractJob |
job
The job which contains all parameters for its execution and which must be filled at the end of the execution. |
protected UWSException |
lastError
The last error which has occurred during the execution of this thread. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
JobThread(AbstractJob j)
Builds the JobThread instance which will be used by the given job to execute its task. |
Method Summary | |
---|---|
UWSException |
getError()
Gets the last error which has occurred during the execution of this thread. |
AbstractJob |
getExecutedJob()
Gets the job instance associated to this thread. |
boolean |
isFinished()
Indicates whether the AbstractJob.jobWork() method has been called or not. |
void |
run()
Tests the execution phase of the job: if not EXECUTING , nothing is done...the thread ends immediately. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final AbstractJob job
protected UWSException lastError
protected boolean finished
AbstractJob.jobWork()
has been called and finished, or not.
Constructor Detail |
---|
public JobThread(AbstractJob j) throws UWSException
j
- The associated job.
UWSException
- If the given job is null.Method Detail |
---|
public final AbstractJob getExecutedJob()
public final UWSException getError()
public final boolean isFinished()
AbstractJob.jobWork()
method has been called or not.
public void run()
EXECUTING
, nothing is done...the thread ends immediately.AbstractJob.jobWork()
method.COMPLETED
if not interrupted, else ABORTED
.
If any InterruptedException
occurs the job phase is only set to ABORTED
.
If any UWSException
occurs while the phase is EXECUTING
the job phase
is set to ERROR
and an error summary is created.
Whatever is the exception, it will always be available thanks to the getError()
after execution.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
AbstractJob.jobWork()
,
AbstractJob.setPhase(ExecutionPhase)
,
AbstractJob.publishExecutionError(UWSException)
,
UWSToolBox.publishErrorSummary(AbstractJob, String, ErrorType)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |