|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ScopedExclusionService
Classes implementing this interface let you execute code guarded by mutual exclusion locks.
You should use methods of this class directly only if there are no adequate methods
in $ScopedExclusionServiceHelper
class.
All taken locks are exclusive. A lock is always taken in a scope. For example a lock on PROJECT_DATA scope defined by
project name 'MINE-ALLMINE' would be different than a lock taken on JOB_KEY scope with name 'MINE-ALLMINE'.
You can use any object for locking, but since this service is shared, it's very important to lock the same
objects that other users of service lock within the same exclusion scope. That's why use of ExclusionScopeType or, better yet
$ScopedExclusionServiceHelper
is strongly recommended.
Nested Class Summary | |
---|---|
static class |
ScopedExclusionService.ExclusionScopeType
Predefined exclusion scopes. |
static interface |
ScopedExclusionService.ExclusiveFunction<F,V,E extends java.lang.Throwable>
Function to call once the object is locked. |
static interface |
ScopedExclusionService.GeneratorCallable<V,E extends java.lang.Throwable>
Generator called to generate new names for objects. |
Method Summary | ||
---|---|---|
|
withLock(java.lang.Enum<?> scopeType,
S objectToLock,
ScopedExclusionService.ExclusiveFunction<S,V,E> function)
Executes function with lock taken in a given scope and object name. |
|
|
withNewLockedObject(java.lang.Enum<?> generationScope,
S objectToLockDuringGeneration,
java.lang.Enum<?> generatedObjectScope,
ScopedExclusionService.GeneratorCallable<S,F> objectGenerator,
ScopedExclusionService.ExclusiveFunction<S,V,E> function)
Executes code with a new, unique name generated within given exclusion scope and locked for exclusive use. |
Method Detail |
---|
<S,V,E extends java.lang.Throwable> V withLock(@NotNull java.lang.Enum<?> scopeType, @NotNull S objectToLock, @NotNull ScopedExclusionService.ExclusiveFunction<S,V,E> function) throws E extends java.lang.Throwable
scopeType
- type of scope (if we wanted to lock a Job, this would be JOB_KEY - jobs are locked by key)objectToLock
- object to lock within scope (if we wanted to lock a Job, this would be job key)function
- the function to call
E
- exception thrown from function
E extends java.lang.Throwable
<S,V,E extends java.lang.Throwable,F extends java.lang.Throwable> V withNewLockedObject(@NotNull java.lang.Enum<?> generationScope, @Nullable S objectToLockDuringGeneration, @Nullable java.lang.Enum<?> generatedObjectScope, @NotNull ScopedExclusionService.GeneratorCallable<S,F> objectGenerator, @NotNull ScopedExclusionService.ExclusiveFunction<S,V,E> function) throws E extends java.lang.Throwable, F extends java.lang.Throwable
E extends java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |