com.atlassian.jira.util
Class Lock

java.lang.Object
  extended by com.atlassian.jira.util.Lock

public class Lock
extends Object

Used to lock resources using a file system file as a lock


Field Summary
static long LOOP_WAIT_TIME
           
 
Constructor Summary
Lock(String fileName)
           
Lock(String directoryName, String fileName)
           
 
Method Summary
 String getLockFilePath()
           
 boolean isLocked()
           
 boolean obtain()
           
 boolean obtain(long timeout)
          Try to obtain a lock, wait for timeout ms if necessary
 void release()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOOP_WAIT_TIME

public static final long LOOP_WAIT_TIME
See Also:
Constant Field Values
Constructor Detail

Lock

public Lock(String fileName)

Lock

public Lock(String directoryName,
            String fileName)
Method Detail

obtain

public boolean obtain()
               throws IOException
Throws:
IOException

obtain

public boolean obtain(long timeout)
               throws IOException
Try to obtain a lock, wait for timeout ms if necessary

Parameters:
timeout - number of milliseconds to wait for (if necessary)
Returns:
try if the lock was successfully obtained, false otherwise
Throws:
IOException - if an error occurs creating the lock

release

public void release()

isLocked

public boolean isLocked()

getLockFilePath

public String getLockFilePath()


Copyright © 2002-2013 Atlassian. All Rights Reserved.