com.atlassian.bamboo.core
Class ScopedExclusionServiceImpl

java.lang.Object
  extended by com.atlassian.bamboo.core.ScopedExclusionServiceImpl
All Implemented Interfaces:
ScopedExclusionService

public class ScopedExclusionServiceImpl
extends java.lang.Object
implements ScopedExclusionService


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.bamboo.core.ScopedExclusionService
ScopedExclusionService.ExclusionScopeType, ScopedExclusionService.ExclusiveFunction<F,V,E extends java.lang.Throwable>, ScopedExclusionService.GeneratorCallable<V,E extends java.lang.Throwable>
 
Constructor Summary
ScopedExclusionServiceImpl()
           
 
Method Summary
static
<T> com.google.common.cache.Cache<T,java.util.concurrent.locks.ReadWriteLock>
weakReadWriteLockFactory()
           
<S,V,E extends java.lang.Throwable>
V
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.
<S,V,E extends java.lang.Throwable,F extends java.lang.Throwable>
V
withNewLockedObject(java.lang.Enum<?> generationScopeType, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScopedExclusionServiceImpl

public ScopedExclusionServiceImpl()
Method Detail

weakReadWriteLockFactory

public static <T> com.google.common.cache.Cache<T,java.util.concurrent.locks.ReadWriteLock> weakReadWriteLockFactory()

withNewLockedObject

public <S,V,E extends java.lang.Throwable,F extends java.lang.Throwable> V withNewLockedObject(@NotNull
                                                                                               java.lang.Enum<?> generationScopeType,
                                                                                               @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
Description copied from interface: ScopedExclusionService
Executes code with a new, unique name generated within given exclusion scope and locked for exclusive use. Objects to lock are generated by objectGenerator. If the generated object is already locked, the generator will be asked for a new object. The whole generation (including all unsuccesful lock attempts) will be run with an exclusive lock held on objectToLockDuringGeneration within generationScope. As soon as a valid object, locked within generatedObjectScope is generated: - other generations within the same scope may continue and - the function will be called. - the generation lock is dropped

Specified by:
withNewLockedObject in interface ScopedExclusionService
Throws:
E extends java.lang.Throwable

withLock

public <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
Description copied from interface: ScopedExclusionService
Executes function with lock taken in a given scope and object name.

Specified by:
withLock in interface ScopedExclusionService
Parameters:
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
Returns:
the result of function
Throws:
E - exception thrown from function
E extends java.lang.Throwable


Copyright © 2013 Atlassian Software Systems Pty Ltd. All Rights Reserved.