Interface RepositoryLock
repository while an operation is performed.
Separate instances of this interface are not related. Locking a repository in one instance
does not lock it in any other. The intention is to allow grouping operations that perform similar
processing, or rely on the same repository data, so that only one is running on a given repository at a time, using
multiple locks when different bands of processing can be performed concurrently.
Note: When used by plugin developers, no instance of this lock can ever prevent the host application from performing any of its own processing on any aspect of a repository.
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<T,E extends Exception>
TPerforms the providedoperationwhile holding a lock on the specifiedrepository.<T,E extends Exception>
TwithLock(Repository repository, Operation<T, E> operation) Performs the providedoperationwhile holding a lock on the specifiedrepository.
-
Method Details
-
withLock
Performs the providedoperationwhile holding a lock on the specifiedrepository.Note: Locking a repository by ID or by
Repositoryinstance acquires the same underlying lock.- Type Parameters:
T- the return type of the perform operationE- the type of Throwable that can be thrown from perform.- Parameters:
repositoryId- theIDof the repository to lockoperation- theoperationto perform while holding the lock- Returns:
- the result of
performingthe operation - Throws:
E- if theoperationfails
-
withLock
<T,E extends Exception> T withLock(@Nonnull Repository repository, @Nonnull Operation<T, E> operation) throws EPerforms the providedoperationwhile holding a lock on the specifiedrepository.Note: Locking a repository by ID or by
Repositoryinstance acquires the same underlying lock.- Type Parameters:
T- the return type of the perform operationE- the type of Throwable that can be thrown from perform.- Parameters:
repository- therepositoryto lockoperation- theoperationto perform while holding the lock- Returns:
- the result of
performingthe operation - Throws:
E- if theoperationfails
-