@OpenApiAll
public final class IdleJobService
extends java.lang.Object
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.
Job
Modifier and Type | Method and Description |
---|---|
void |
addJob(Job job)
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 |
addJob(Job job,
long interval,
int sessionCompletionDelay,
boolean onIdle)
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
|
static IdleJobService |
getInstance()
Gets the singleton job service.
|
void |
removeJob(Job job)
Removes job from the service.
|
void |
runJob(Job job)
Immediately runs the job, without checking if it needs to run
|
public static IdleJobService getInstance()
public void addJob(Job job)
job
- to add to the service.public void addJob(Job job, long interval, int sessionCompletionDelay, boolean onIdle)
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. See SessionManager
onIdle
- only execute this job when MagicDraw is idle for the provided interval of seconds
Method is thread safe.public void removeJob(Job job)
job
- rule to removepublic void runJob(Job job)
job
- job that was previously added to the this service