Interface ResourceLockProvider

All Known Implementing Classes:
ExternalResourceLockProvider

public interface ResourceLockProvider
Provides the ability to lock and unlock resources.
Author:
Jacob Mitash
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    finishLock(String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Update the status of the lock to indicate the associated process is complete.
    obtainLock(String contextId, String conceptKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Obtains a permanent resource lock, typically used for idempotency messages.
    default String
    obtainTemporalLock(String contextId, String conceptKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Obtains a temporal resource lock.
    obtainTemporalLock(String contextId, String conceptKey, Duration lockTtl, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Obtains a temporal resource lock.
    void
    releaseLock(String token, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Releases a resource lock using a token.
  • Method Details

    • obtainLock

      String obtainLock(String contextId, String conceptKey, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Obtains a permanent resource lock, typically used for idempotency messages.
      Parameters:
      contextId - the context ID of the entity to lock
      conceptKey - some key indicating what is being locked or by who
      contextInfo - the context of the request
      Returns:
      a token that can be used to release the lock
    • obtainTemporalLock

      default String obtainTemporalLock(String contextId, String conceptKey, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Obtains a temporal resource lock. This lock is automatically released after a very short duration. By default, the duration is 10 seconds and can be changed via the "broadleaf.order.web.order-lock-ttl" configuration property.
      Parameters:
      contextId - the context ID of the entity to lock
      conceptKey - some key indicating what is being locked or by who
      contextInfo - the context of the request
      Returns:
      a token that can be used to release the lock
      Since:
      Order Operations Service 3.0.0, Release Train 3.0.0
    • obtainTemporalLock

      String obtainTemporalLock(String contextId, String conceptKey, @Nullable Duration lockTtl, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Obtains a temporal resource lock. This lock is automatically released after lockTtl if specified. By default, if the lockTtl is null, the duration configured via the "broadleaf.order.web.order-lock-ttl" property will be used.
      Parameters:
      contextId - the context ID of the entity to lock
      conceptKey - some key indicating what is being locked or by who
      lockTtl - amount of time that an order lock is held, before it expires
      contextInfo - the context of the request
      Returns:
      a token that can be used to release the lock
      Since:
      Order Operations Service 3.0.0, Release Train 3.0.0
    • releaseLock

      void releaseLock(String token, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Releases a resource lock using a token. The token should be obtained via obtainLock(String, String, ContextInfo).
      Parameters:
      token - the token tied to the lock which should be released
      contextInfo - the context of the request
    • finishLock

      void finishLock(String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Update the status of the lock to indicate the associated process is complete.
      Parameters:
      lockToken - The unique token that was provided when the lock was obtained
      contextInfo - the context of the request