Class BackgroundJobStatusDecorator<T>
- java.lang.Object
-
- org.evolvis.tartools.backgroundjobs.BackgroundJobStatusDecorator<T>
-
- All Implemented Interfaces:
BackgroundJobInfo,BackgroundJobStatus<T>
public abstract class BackgroundJobStatusDecorator<T> extends java.lang.Object implements BackgroundJobStatus<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.evolvis.tartools.backgroundjobs.BackgroundJobInfo
BackgroundJobInfo.State
-
-
Field Summary
Fields Modifier and Type Field Description protected BackgroundJobStatus<T>delegatee
-
Constructor Summary
Constructors Constructor Description BackgroundJobStatusDecorator(BackgroundJobStatus<T> delegatee)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Request the cancellation of a job.voidaddJobListener(JobListener l)protected BackgroundJobStatus<T>getDelegatee()java.lang.StringgetDescription()The human-readable description for this job.java.lang.StringgetId()The unique identifier assigned to this job by the scheduler.java.lang.Class<?>getJobClass()The class implementing the actual work.longgetLastModified()longgetStartTime()BackgroundJobInfo.StategetState()intgetWorkDone()Get the amount of work that is already done.intgetWorkTotal()Get the total amount of work.voidjoin(long timeout)Join the thread executing the job.voidremoveJobListener(JobListener l)Tresult()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, wait
-
Methods inherited from interface org.evolvis.tartools.backgroundjobs.BackgroundJobInfo
isVisible
-
Methods inherited from interface org.evolvis.tartools.backgroundjobs.BackgroundJobStatus
isCancellationSupported
-
-
-
-
Field Detail
-
delegatee
protected final BackgroundJobStatus<T> delegatee
-
-
Constructor Detail
-
BackgroundJobStatusDecorator
public BackgroundJobStatusDecorator(BackgroundJobStatus<T> delegatee)
-
-
Method Detail
-
getState
public BackgroundJobInfo.State 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
public java.lang.String getId()
Description copied from interface:BackgroundJobInfoThe unique identifier assigned to this job by the scheduler.- Specified by:
getIdin interfaceBackgroundJobInfo- Returns:
- the id.
-
join
public void join(long timeout) throws java.lang.InterruptedExceptionDescription 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:
java.lang.InterruptedException
-
getDescription
public java.lang.String getDescription()
Description copied from interface:BackgroundJobInfoThe human-readable description for this job.- Specified by:
getDescriptionin interfaceBackgroundJobInfo- Returns:
- the description.
-
result
public T result() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
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:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionException
-
getJobClass
public java.lang.Class<?> 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
public void addJobListener(JobListener l)
- Specified by:
addJobListenerin interfaceBackgroundJobStatus<T>
-
removeJobListener
public void removeJobListener(JobListener l)
- 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
protected BackgroundJobStatus<T> getDelegatee()
-
-