Class MediaObjectLocker

java.lang.Object
nl.vpro.domain.media.MediaObjectLocker

public class MediaObjectLocker extends Object
Tool to make sure that the 'authority' related dropboxes and other services don't run at the same time for the same mid.

It may be better to (also) introduce more decent hibernate locking (MSE-3751)

This basically wraps ObjectLocker, but keeps a separate map of locked objects, dedicated to media identifiables

Also, it defines some annotations (for use with MediaObjectLockerAspect, to facilitate locking via annotation), and some utility methods.

Since:
5.5
Author:
Michiel Meeuwissen
  • Constructor Details

    • MediaObjectLocker

      public MediaObjectLocker()
  • Method Details

    • assertNoMidLock

      public static void assertNoMidLock(String description)
    • executeInNewTransactionWithMidLock

      public static <T> T executeInNewTransactionWithMidLock(@NonNull TransactionService transactionService, String mid, @NonNull String reason, @NonNull Callable<T> callable)
      Run in a new transaction, but before that lock the mid.

      Make sure not to be in a transaction already.

    • executeInNewTransactionWithCorrelationLock

      public static <T> T executeInNewTransactionWithCorrelationLock(@NonNull TransactionService transactionService, MediaIdentifiable.Correlation correlation, @NonNull String reason, @NonNull Callable<T> callable)
      Run in a new transaction, but before that lock the mid.

      Make sure not to be in a transaction already.

      Since:
      7.1
    • executeInNewTransactionWithMidLock

      public static <T> T executeInNewTransactionWithMidLock(@NonNull DoAsTransactionService transactionService, @NonNull Trusted user, String mid, @NonNull String reason, @NonNull Callable<T> callable)
      Run in a new transaction, but before that lock the mid.

      Make sure not to be in a transaction already.

    • executeInNewTransactionWithCorrelationLock

      public static <T> T executeInNewTransactionWithCorrelationLock(@NonNull DoAsTransactionService transactionService, @NonNull Trusted user, MediaIdentifiable.Correlation correlation, @NonNull String reason, @NonNull Callable<T> callable)
      Run in a new transaction, but before that lock the mid.

      Make sure not to be in a transaction already.

      Since:
      7.1
    • getWithMidLock

      public static <T> T getWithMidLock(String mid, @NonNull String reason, @NonNull Supplier<T> callable)
    • withMidLock

      public static void withMidLock(String mid, @NonNull String reason, @NonNull Runnable runnable)
    • withMidLock

      public static <T> T withMidLock(String mid, @NonNull String reason, @NonNull Callable<T> callable)
    • withCorrelationLock

      public static <T> T withCorrelationLock(@NonNull MediaIdentifiable.Correlation lock, @NonNull String reason, @NonNull Callable<T> callable)
    • withCorrelationLock

      public static <T> T withCorrelationLock(@NonNull MediaIdentifiable lockHolder, @NonNull String reason, @NonNull Callable<T> callable)