Package com.nomagic.magicdraw.job
Class IdleJobService
java.lang.Object
com.nomagic.magicdraw.job.IdleJobService
Idle job service allows to add jobs which can be executed when application is idle.
Application decides when it is the most appropriate to execute the job without getting application into an inconsistent state.
Example usage:
Job job = new Job() { public boolean needsExecute() { return true; } public void execute(ProgressStatus progressStatus) throws Exception { // Do necessary work in the session. } public void finished() { // Cleanup after job is finished. } public String getName() { return "My Job"; } }; IdleJobService.getInstance().addJob(job); // Remove the job when it is no longer necessary. IdleJobService.getInstance().removeJob(job); For more information please refer to the JobExample in the examples directory.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a job to the service to run every two seconds If the same job was added previously, it will be first canceled and then re-added Method is thread safe.void
Adds a job to the service to repeatedly run on the given interval If the same job was added previously, it will be canceled and re-addedstatic IdleJobService
Gets the singleton job service.void
Removes job from the service.void
Immediately runs the job, without checking if it needs to run
-
Method Details
-
getInstance
Gets the singleton job service.- Returns:
- job service.
-
addJob
Adds a job to the service to run every two seconds If the same job was added previously, it will be first canceled and then re-added Method is thread safe.- Parameters:
job
- to add to the service.
-
addJob
Adds a job to the service to repeatedly run on the given interval If the same job was added previously, it will be canceled and re-added- Parameters:
job
- a job to executeinterval
- duration between two executions of the same interval seconds.sessionCompletionDelay
- how many seconds must past from the last session close. SeeSessionManager
onIdle
- only execute this job when MagicDraw is idle for the provided interval of seconds Method is thread safe.
-
removeJob
Removes job from the service. Method is thread safe.- Parameters:
job
- rule to remove
-
runJob
Immediately runs the job, without checking if it needs to run- Parameters:
job
- job that was previously added to the this service
-