|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object uws.job.manager.DefaultDestructionManager
public class DefaultDestructionManager
The default implementation of the DestructionManager
interface.
Its goal is to manage the automatic destruction any given jobs.
Jobs can be added thanks to update(AbstractJob)
and removed with remove(AbstractJob)
.
All added jobs are stored in a TreeSet
which sorts them by ascending destruction time.
The job which must be destroyed in first is used to start a timer.
This one will destroyed the job once its destruction time is reached.
The list of jobs to destroy is supposed to be updated each time the destruction time of a job is changed. This update works only if
the job knows its jobs list (AbstractJob.getJobList()
!= null) and its jobs list has a destruction manager.
Nested Class Summary | |
---|---|
protected static class |
DefaultDestructionManager.TimeComparator
Lets a TreeSet or a TreeMap sorting AbstractJob instances in an ascending order
and according to their destruction time. |
Field Summary | |
---|---|
protected java.util.Date |
currentDate
The date used by the timer to trigger the destruction of currentJob . |
protected AbstractJob |
currentJob
The job currently planned for destruction. |
protected java.util.TreeSet<AbstractJob> |
jobsToDestroy
The list of jobs to destroy. |
protected java.util.Timer |
timDestruction
Timer for the job destruction time. |
Constructor Summary | |
---|---|
DefaultDestructionManager()
Builds the default destruction manager. |
Method Summary | |
---|---|
protected void |
destroyJob(AbstractJob job)
Merely destroys the given job (if not null). |
int |
getNbJobsToDestroy()
Gets the total number of jobs planned to be destroyed. |
java.util.Date |
getNextDestruction()
Gets the destruction date/time of the job currently planned for destruction. |
java.lang.String |
getNextJobToDestroy()
Gets the ID of the job currently planned for destruction. |
boolean |
isRunning()
Returns true if currentDate is different from null. |
void |
refresh()
First, check the currently planned job: if currentDate is past, the timer is stopped. |
void |
remove(AbstractJob job)
Merely removes the given job from the list of jobs to destroyed. |
protected void |
stop()
Stops the timer if running and set to null timDestruction , currentDate and currentJob . |
void |
update(AbstractJob job)
This function does something only if the given job knows its jobs list and has a valid destruction time. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.util.TreeSet<AbstractJob> jobsToDestroy
DefaultDestructionManager.TimeComparator
.
protected transient java.util.Timer timDestruction
protected AbstractJob currentJob
protected java.util.Date currentDate
currentJob
.
Constructor Detail |
---|
public DefaultDestructionManager()
DefaultDestructionManager.TimeComparator
Method Detail |
---|
protected final void stop()
timDestruction
, currentDate
and currentJob
.
protected final void destroyJob(AbstractJob job)
job
- The job to destroy.AbstractJob.getJobList()
,
JobList.destroyJob(String)
public final boolean isRunning()
Returns true if currentDate
is different from null.
Note:
If this object has just been deserialized, timDestruction
is NULL.
In this case this function resets it, obviously if it is supposed to run (currentDate
!= null).
isRunning
in interface DestructionManager
DestructionManager.isRunning()
public final java.util.Date getNextDestruction()
DestructionManager
getNextDestruction
in interface DestructionManager
public final java.lang.String getNextJobToDestroy()
DestructionManager
getNextJobToDestroy
in interface DestructionManager
public final int getNbJobsToDestroy()
DestructionManager
getNbJobsToDestroy
in interface DestructionManager
public void refresh()
currentDate
is past, the timer is stopped.
refresh
in interface DestructionManager
DestructionManager.refresh()
,
stop()
,
destroyJob(AbstractJob)
public void update(AbstractJob job)
destroyJob(AbstractJob)
).refresh()
).
update
in interface DestructionManager
job
- The job whose the destruction time may have changed.DestructionManager.update(uws.job.AbstractJob)
,
destroyJob(AbstractJob)
,
refresh()
public void remove(AbstractJob job)
remove
in interface DestructionManager
job
- The job to remove.DestructionManager.remove(uws.job.AbstractJob)
,
stop()
,
refresh()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |