Class FileLockerImpl

  • All Implemented Interfaces:
    FileLocker

    public class FileLockerImpl
    extends java.lang.Object
    implements FileLocker
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String LOCKFILE_SUFFIX  
      private org.eclipse.osgi.service.datalocation.Location lockFileLocation  
      (package private) java.io.File lockMarkerFile  
    • Constructor Summary

      Constructors 
      Constructor Description
      FileLockerImpl​(java.io.File file, org.eclipse.osgi.service.datalocation.Location anyLocation)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isLocked()
      Whether the file associated with this locker object is currently locked (by this process or any other process).
      void lock()
      Equivalent to {FileLocker.lock(long) with a timeout argument of 10000 milliseconds.
      void lock​(long timeout)
      Attempt to lock the file associated with this locker object.
      void release()
      Release the lock if acquired.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • lockFileLocation

        private final org.eclipse.osgi.service.datalocation.Location lockFileLocation
      • lockMarkerFile

        final java.io.File lockMarkerFile
    • Constructor Detail

      • FileLockerImpl

        public FileLockerImpl​(java.io.File file,
                              org.eclipse.osgi.service.datalocation.Location anyLocation)
    • Method Detail

      • lock

        public void lock​(long timeout)
        Description copied from interface: FileLocker
        Attempt to lock the file associated with this locker object. Note that technically, not the file itself is locked, but an empty marker file next to it.
        Specified by:
        lock in interface FileLocker
        Parameters:
        timeout - timeout in milliseconds
      • release

        public void release()
        Description copied from interface: FileLocker
        Release the lock if acquired. Also removes the lock marker file.
        Specified by:
        release in interface FileLocker
      • isLocked

        public boolean isLocked()
        Description copied from interface: FileLocker
        Whether the file associated with this locker object is currently locked (by this process or any other process).
        Specified by:
        isLocked in interface FileLocker