com.atlassian.jira.util
Class Lock

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

public class Lock
extends java.lang.Object

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


Field Summary
static long LOOP_WAIT_TIME
           
 
Constructor Summary
Lock(java.lang.String fileName)
           
Lock(java.lang.String directoryName, java.lang.String fileName)
           
 
Method Summary
 java.lang.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(java.lang.String fileName)

Lock

public Lock(java.lang.String directoryName,
            java.lang.String fileName)
Method Detail

obtain

public boolean obtain()
               throws java.io.IOException
Throws:
java.io.IOException

obtain

public boolean obtain(long timeout)
               throws java.io.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:
java.io.IOException - if an error occurs creating the lock

release

public void release()

isLocked

public boolean isLocked()

getLockFilePath

public java.lang.String getLockFilePath()


Copyright © 2002-2010 Atlassian. All Rights Reserved.