Methods Summary |
---|
private java.io.ObjectInputStream | getIn()
final FileInputStream fis = new FileInputStream(storeImpl.getStore());
getReadLock(fis.getChannel());
if (fis.available() > 0){
return new ObjectInputStream(fis);
} else {
fis.close();
return null;
}
|
private java.nio.channels.FileLock | getReadLock(java.nio.channels.FileChannel ch)
return obtainLock(ch, true);
|
private java.nio.channels.FileLock | getWriteLock(java.nio.channels.FileChannel ch)get a write lock on the given channel
return obtainLock(ch, false);
|
public long | lastModified() return 0L ;
|
public void | lock()
final RandomAccessFile raf = new RandomAccessFile(storeImpl.getLock(),
"rws");
getWriteLock(raf.getChannel());
storeImpl.setState(new Locked(storeImpl, raf));
|
private java.nio.channels.FileLock | obtainLock(java.nio.channels.FileChannel channel, boolean shared)
FileLock lock = null;
int attempts = 0;
try{
/** Using 0x7fffffff in place of Long.MAX_VALUE. Bug # 4719967,4719605 **/
while ((lock = channel.tryLock(0L, 0x7fffffff, shared)) == null && attempts++ < ATTEMPTS){
Thread.currentThread().sleep(TIMEOUT);
}
}
catch (InterruptedException e){
throw new TimeoutException();
}
if (lock == null) {
throw new TimeoutException();
}
return lock;
|
public synchronized java.lang.Object | readObject()
ObjectInputStream in = null;
Object o = null;
try{
in = getIn();
o = (in != null ? in.readObject() : null) ;
}
catch (EOFException e){
o = null; // this occurs if file is empty
}
finally {
if (in != null) {
in.close();
}
}
return o;
|
public void | unlock()
|
public void | writeObject(java.lang.Object o)
throw new IllegalStateException("Unlocked state - writeObject() not allowed");
|