public class FileLock extends Object implements Runnable
Modifier and Type | Field and Description |
---|---|
static int |
LOCK_FILE
This locking method means the cooperative file locking protocol should be
used.
|
static int |
LOCK_FS
Use the file system to lock the file; don't use a separate lock file.
|
static int |
LOCK_NO
This locking method means no locking is used at all.
|
static int |
LOCK_SERIALIZED
This locking method means multiple writers are allowed, and they
synchronize themselves.
|
static int |
LOCK_SOCKET
This locking method means a socket is created on the given machine.
|
Constructor and Description |
---|
FileLock(TraceSystem traceSystem,
String fileName,
int sleep)
Create a new file locking object.
|
Modifier and Type | Method and Description |
---|---|
static int |
getFileLockMethod(String method)
Get the file locking method type given a method name.
|
String |
getUniqueId() |
Properties |
load()
Load the properties file.
|
void |
lock(int fileLockMethod)
Lock the file if possible.
|
void |
run() |
Properties |
save()
Save the lock file.
|
void |
setProperty(String key,
String value)
Add or change a setting to the properties.
|
void |
unlock()
Unlock the file.
|
public static final int LOCK_NO
public static final int LOCK_FILE
public static final int LOCK_SOCKET
public static final int LOCK_SERIALIZED
public static final int LOCK_FS
public FileLock(TraceSystem traceSystem, String fileName, int sleep)
traceSystem
- the trace system to usefileName
- the file namesleep
- the number of milliseconds to sleeppublic void lock(int fileLockMethod)
fileLockMethod
- the file locking method to useDbException
- if locking was not successfulpublic void unlock()
public void setProperty(String key, String value)
key
- the keyvalue
- the valuepublic Properties save()
public Properties load()
public static int getFileLockMethod(String method)
method
- the method nameDbException
- if the method name is unknownpublic String getUniqueId()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.