Class Lock

  • All Implemented Interfaces:
    DatastoreAndSqlEntity, DatastoreEntity, SqlEntity, java.io.Serializable, java.lang.Cloneable

    @Entity
    public class Lock
    extends ImmutableObject
    implements DatastoreAndSqlEntity, java.io.Serializable
    A lock on some shared resource.

    Locks are either specific to a tld or global to the entire system, in which case a scope of GLOBAL is used.

    This is the "barebone" lock implementation, that requires manual locking and unlocking. For safe calls that automatically lock and unlock, see LockHandler.

    See Also:
    Serialized Form
    • Constructor Detail

      • Lock

        public Lock()
    • Method Detail

      • getExpirationTime

        public org.joda.time.DateTime getExpirationTime()
      • acquire

        public static java.util.Optional<Lock> acquire​(java.lang.String resourceName,
                                                       @Nullable
                                                       java.lang.String tld,
                                                       org.joda.time.Duration leaseLength,
                                                       RequestStatusChecker requestStatusChecker,
                                                       boolean checkThreadRunning)
        Try to acquire a lock. Returns absent if it can't be acquired.
      • release

        public void release()
        Release the lock.