Package com.im.commons.progress
Class UIBackgroundRunnerRW
- java.lang.Object
-
- com.im.commons.progress.BackgroundRunner
-
- com.im.commons.progress.UIBackgroundRunnerRW
-
public abstract class UIBackgroundRunnerRW extends BackgroundRunner
An extension ofUIBackgroundRunnerROwhich is able to lock the given DFLockable and use the lock in the background task. Lock is automatically released when action is finished.When the
DFLockableis already locked, the background task will try to lock repeatedly, waitingLOCK_RETRY_DELAYmilliseconds between retries. The implementation will attempt to lock the DFLockable at mostMAX_LOCK_RETRIEStimes.When the attempts to lock are exhausted, or the
DFLockable.isLockedForever()indicates that the DFLockable can never be locked, the task will fail withAlreadyLockedException. Thephase1Exception(java.lang.Exception)andBackgroundRunner.phase1Finally()will be called for proper error reporting and state cleanup.- Author:
- Petr Hamernik
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.im.commons.progress.BackgroundRunner
BackgroundRunner.BackgroundTask
-
-
Constructor Summary
Constructors Constructor Description UIBackgroundRunnerRW(DFLockable lockable, java.lang.String taskName, boolean cancellable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TaskcreateTask()DFEnvironmentRWgetEnvironment()protected java.util.concurrent.ScheduledExecutorServicegetExecutorService()We need single thread executor service per lockable.booleanphase1Cancelled(CancelException exc)booleanphase1Exception(java.lang.Exception exc)All subclasses must override this method and provide more user-friendly error notification.protected voidphase1FinallyInternal()-
Methods inherited from class com.im.commons.progress.BackgroundRunner
failTask, getCreateLock, getDelay, getTask, interrupt, phase1Finally, phase1InRequestProcessor, phase2InAWT, processTheTask, restart, start
-
-
-
-
Constructor Detail
-
UIBackgroundRunnerRW
public UIBackgroundRunnerRW(DFLockable lockable, java.lang.String taskName, boolean cancellable)
-
-
Method Detail
-
createTask
protected Task createTask()
- Overrides:
createTaskin classBackgroundRunner- Returns:
- The locking object that guards creation of a new task. Use when you need to query task or other things computed during start()
-
getEnvironment
public DFEnvironmentRW getEnvironment()
-
phase1Cancelled
public boolean phase1Cancelled(CancelException exc)
- Overrides:
phase1Cancelledin classBackgroundRunner- Returns:
- when true this runner continues with AWT (second) phase. If false, the AWT phase is skipped.
-
phase1FinallyInternal
protected final void phase1FinallyInternal()
- Overrides:
phase1FinallyInternalin classBackgroundRunner
-
getExecutorService
protected java.util.concurrent.ScheduledExecutorService getExecutorService()
We need single thread executor service per lockable.- Overrides:
getExecutorServicein classBackgroundRunner- Returns:
- returns ExecutorService for use in this bg runner
-
phase1Exception
public boolean phase1Exception(java.lang.Exception exc)
Description copied from class:BackgroundRunnerAll subclasses must override this method and provide more user-friendly error notification.- Overrides:
phase1Exceptionin classBackgroundRunner- Returns:
- when true this runner continues with AWT (second) phase. If false, the AWT phase is skipped.
-
-