Class BackgroundJobStatusDecorator<T>
java.lang.Object
org.evolvis.tartools.backgroundjobs.BackgroundJobStatusDecorator<T>
- All Implemented Interfaces:
BackgroundJobInfo,BackgroundJobStatus<T>
public abstract class BackgroundJobStatusDecorator<T>
extends Object
implements BackgroundJobStatus<T>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.evolvis.tartools.backgroundjobs.BackgroundJobInfo
BackgroundJobInfo.State -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Request the cancellation of a job.voidprotected BackgroundJobStatus<T>The human-readable description for this job.getId()The unique identifier assigned to this job by the scheduler.Class<?>The class implementing the actual work.longlonggetState()intGet the amount of work that is already done.intGet the total amount of work.voidjoin(long timeout) Join the thread executing the job.voidresult()Obtain the result produced by the job, waiting for its completion if necessary.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.evolvis.tartools.backgroundjobs.BackgroundJobInfo
isVisibleMethods inherited from interface org.evolvis.tartools.backgroundjobs.BackgroundJobStatus
isCancellationSupported
-
Field Details
-
delegatee
-
-
Constructor Details
-
BackgroundJobStatusDecorator
-
-
Method Details
-
getState
- Specified by:
getStatein interfaceBackgroundJobInfo- Returns:
- the current
BackgroundJobInfo.Stateof the job.
-
getWorkDone
public int getWorkDone()Description copied from interface:BackgroundJobInfoGet the amount of work that is already done. Returns the number of "units of work" that have been completed by the job so far. UseBackgroundJobInfo.getWorkTotal()to put this into relation.- Specified by:
getWorkDonein interfaceBackgroundJobInfo- Returns:
- number of completed "units of work"
-
getWorkTotal
public int getWorkTotal()Description copied from interface:BackgroundJobInfoGet the total amount of work.
Returns the total number of "units of work" comprising this job, including the part that is already done.BackgroundJob-implementations will typically provide a value in an early stage of processing. They are however not obliged to do so, so the expected total amount may not be known yet. In particular,BackgroundJobare allowed to to update this value if new information about the total amount of work to be done becomes available.- Specified by:
getWorkTotalin interfaceBackgroundJobInfo- Returns:
- the expected total amount of work in "units of work".
-
abort
public void abort()Description copied from interface:BackgroundJobStatusRequest the cancellation of a job.
This will try to interrupt the thread executing the job and it will makeBackgroundJobMonitor.isAborting()return false. Nevertheless it may take some time until the job actually stops whatever it is doing.- Specified by:
abortin interfaceBackgroundJobStatus<T>
-
getId
Description copied from interface:BackgroundJobInfoThe unique identifier assigned to this job by the scheduler.- Specified by:
getIdin interfaceBackgroundJobInfo- Returns:
- the id.
-
join
Description copied from interface:BackgroundJobStatusJoin the thread executing the job.- Specified by:
joinin interfaceBackgroundJobStatus<T>- Parameters:
timeout- the maximum number of milliseconds to wait for the job.- Throws:
InterruptedException
-
getDescription
Description copied from interface:BackgroundJobInfoThe human-readable description for this job.- Specified by:
getDescriptionin interfaceBackgroundJobInfo- Returns:
- the description.
-
result
Description copied from interface:BackgroundJobStatusObtain the result produced by the job, waiting for its completion if necessary.- Specified by:
resultin interfaceBackgroundJobStatus<T>- Returns:
- the result.
- Throws:
InterruptedExceptionExecutionException
-
getJobClass
Description copied from interface:BackgroundJobInfoThe class implementing the actual work. This will typically be an Implementation ofBackgroundJob, but Schedulers may choose a different approach.- Specified by:
getJobClassin interfaceBackgroundJobInfo- Returns:
- the implementation of the job.
-
addJobListener
- Specified by:
addJobListenerin interfaceBackgroundJobStatus<T>
-
removeJobListener
- Specified by:
removeJobListenerin interfaceBackgroundJobStatus<T>
-
getLastModified
public long getLastModified()- Specified by:
getLastModifiedin interfaceBackgroundJobInfo- Returns:
- the last time at which progress info or state where updated. (Milliseconds since epoch.)
-
getStartTime
public long getStartTime()- Specified by:
getStartTimein interfaceBackgroundJobInfo
-
getDelegatee
-