Class MongoResourceLock

  • All Implemented Interfaces:
    Serializable

    @CompoundIndexes(@CompoundIndex(name="lock_key",def="{\'contextId\' : 1, \'typeAlias\': 1, \'sandboxId\': 1, \'conceptKey\': 1}",unique=true))
    public class MongoResourceLock
    extends Object
    implements Serializable
    Represents a single lock on a resource held in the current datastore. This is often used to prevent concurrent mutating operations on the same resource. A common application of this concept is the locking of sandbox workflow operations on the same Trackable resource.
    Author:
    Jeff Fischer
    See Also:
    Serialized Form
    • Constructor Detail

      • MongoResourceLock

        public MongoResourceLock()
    • Method Detail

      • get_id

        public org.bson.types.ObjectId get_id()
      • getContextId

        public String getContextId()
        The contextId of the Trackable resource to lock
        Returns:
        The contextId of the Trackable resource to lock
      • getTypeAlias

        public String getTypeAlias()
        An alias used to represent the Java type of the resource being locked. This is most often the Java class simple name.
        Returns:
        An alias used to represent the Java type of the resource being locked
      • getSandboxId

        public String getSandboxId()
        The sandboxId in which the workflow operation is taking place.
        Returns:
        The sandboxId in which the workflow operation is taking place.
      • getConceptKey

        public String getConceptKey()
        A generally descriptive key that identifies the overall concept for which the lock is taking place. WorkflowTransitionHelper#LOCK_CONCEPT_KEY is an example that identifies locks for sandbox workflows. Other concept keys may be used to apply locks for the same resource under a different context.
        Returns:
        A generally descriptive key
      • getLocked

        public Boolean getLocked()
        Whether or not the resource is locked
        Returns:
        Whether or not the resource is locked
      • getTimestamp

        public Instant getTimestamp()
        The time at which the lock was set to true
        Returns:
        The time at which the lock was set to true
      • getExpirationTimestamp

        public Instant getExpirationTimestamp()
        The time at which the lock will naturally expire
        Returns:
        The time at which the lock will naturally expire
      • getToken

        public String getToken()
        The token assigned the last time the lock was set to true. The token simply identifies the lock record and can be used to unlock the resource.
        Returns:
        The token assigned the last time the lock was set to true
      • set_id

        public void set_id​(org.bson.types.ObjectId _id)
      • setContextId

        public void setContextId​(String contextId)
        The contextId of the Trackable resource to lock
        Parameters:
        contextId - The contextId of the Trackable resource to lock
      • setTypeAlias

        public void setTypeAlias​(String typeAlias)
        An alias used to represent the Java type of the resource being locked. This is most often the Java class simple name.
        Parameters:
        typeAlias - An alias used to represent the Java type of the resource being locked
      • setSandboxId

        public void setSandboxId​(String sandboxId)
        The sandboxId in which the workflow operation is taking place.
        Parameters:
        sandboxId - The sandboxId in which the workflow operation is taking place.
      • setConceptKey

        public void setConceptKey​(String conceptKey)
        A generally descriptive key that identifies the overall concept for which the lock is taking place. WorkflowTransitionHelper#LOCK_CONCEPT_KEY is an example that identifies locks for sandbox workflows. Other concept keys may be used to apply locks for the same resource under a different context.
        Parameters:
        conceptKey - A generally descriptive key
      • setLocked

        public void setLocked​(Boolean locked)
        Whether or not the resource is locked
        Parameters:
        locked - Whether or not the resource is locked
      • setTimestamp

        public void setTimestamp​(Instant timestamp)
        The time at which the lock was set to true
        Parameters:
        timestamp - The time at which the lock was set to true
      • setExpirationTimestamp

        public void setExpirationTimestamp​(Instant expirationTimestamp)
        The time at which the lock will naturally expire
        Parameters:
        expirationTimestamp - The time at which the lock will naturally expire
      • setToken

        public void setToken​(String token)
        The token assigned the last time the lock was set to true. The token simply identifies the lock record and can be used to unlock the resource.
        Parameters:
        token - The token assigned the last time the lock was set to true
      • canEqual

        protected boolean canEqual​(Object other)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object