Class FileLocker

java.lang.Object
com.aspectran.utils.FileLocker

public class FileLocker extends Object
Used to obtain a lock that can be used to prevent other Aspectran services that use the same persistent store.
Since:
5.1.0
  • Constructor Details

    • FileLocker

      public FileLocker(File lockFile)
      Instantiates a new FileLocker.
      Parameters:
      lockFile - the file to lock
    • FileLocker

      public FileLocker(String basePath)
    • FileLocker

      public FileLocker(String basePath, String filename)
  • Method Details

    • lock

      public boolean lock() throws Exception
      Try to lock the file and return true if the locking succeeds.
      Returns:
      true if the locking succeeds; false if the lock is already held
      Throws:
      Exception - if the lock could not be obtained for any reason
    • release

      public void release() throws Exception
      Releases the lock.
      Throws:
      Exception - if the lock could not be released for any reason