Class NullLock

java.lang.Object
org.pipservices3.components.lock.NullLock
All Implemented Interfaces:
ILock

public class NullLock extends Object implements ILock
Dummy lock implementation that doesn't do anything.

It can be used in testing or in situations when lock is required but shall be disabled.

See Also:
  • Constructor Details

    • NullLock

      public NullLock()
  • Method Details

    • tryAcquireLock

      public boolean tryAcquireLock(String correlationId, String key, int ttl)
      Makes a single attempt to acquire a lock by its key. It returns immediately a positive or negative result.
      Specified by:
      tryAcquireLock in interface ILock
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      key - a unique lock key to acquire.
      ttl - a lock timeout (time to live) in milliseconds.
      Returns:
      true if the lock was acquired and false otherwise.
    • acquireLock

      public void acquireLock(String correlationId, String key, int ttl, long timeout)
      Makes multiple attempts to acquire a lock by its key within give time interval.
      Specified by:
      acquireLock in interface ILock
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      key - a unique lock key to acquire.
      ttl - a lock timeout (time to live) in milliseconds.
      timeout - a lock acquisition timeout.
    • releaseLock

      public void releaseLock(String correlationId, String key)
      Releases prevously acquired lock by its key.
      Specified by:
      releaseLock in interface ILock
      Parameters:
      correlationId - (optional) transaction id to trace execution through call chain.
      key - a unique lock key to release.