public class StoreObjectAccessorLocking extends java.lang.Object implements PersistenceObjectStore.StoreObjectAccessorWithLock
PersistenceObjectStore.StoreObjectAccessor
in a guarded read-write context such that callers will be blocked if another thread
is accessing the object in an incompatible way (e.g. trying to read when someone is writing).
See ReadWriteLock
.
This has no visibility or control over other access to the delegate or underlying object, of course. It can only affect callers coming through this wrapper instance. Thus callers must share instances of this class for a given item.
No locking is done with respect to getLastModifiedDate()
.
Constructor and Description |
---|
StoreObjectAccessorLocking(PersistenceObjectStore.StoreObjectAccessor delegate) |
Modifier and Type | Method and Description |
---|---|
void |
append(java.lang.String val) |
void |
delete() |
boolean |
exists() |
java.lang.String |
get()
gets the object, or null if not found
|
byte[] |
getBytes() |
java.util.Date |
getLastModifiedDate()
last modified date, null if not supported or does not exist
|
java.util.concurrent.locks.ReadWriteLock |
getLockObject()
returns the underlying lock in case callers need more complex synchronization control
|
void |
put(java.lang.String val) |
java.lang.String |
toString() |
void |
waitForCurrentWrites(Duration timeout)
waits for all currently scheduled write lock operations (puts, appends, and deletes) to complete;
but does not wait on or prevent subsequent modifications.
|
public StoreObjectAccessorLocking(PersistenceObjectStore.StoreObjectAccessor delegate)
public java.lang.String get()
PersistenceObjectStore.StoreObjectAccessor
get
in interface PersistenceObjectStore.StoreObjectAccessor
public byte[] getBytes()
getBytes
in interface PersistenceObjectStore.StoreObjectAccessor
public boolean exists()
exists
in interface PersistenceObjectStore.StoreObjectAccessor
public void put(java.lang.String val)
put
in interface PersistenceObjectStore.StoreObjectAccessor
public void append(java.lang.String val)
append
in interface PersistenceObjectStore.StoreObjectAccessor
public void delete()
delete
in interface PersistenceObjectStore.StoreObjectAccessor
public void waitForCurrentWrites(Duration timeout) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
PersistenceObjectStore.StoreObjectAccessorWithLock
for more complex uses, readers should getLockObject().readLock().lockInterruptibly()
and ensure they subsequently unlock()
it of course. see PersistenceObjectStore.StoreObjectAccessorWithLock.getLockObject()
.
waitForCurrentWrites
in interface PersistenceObjectStore.StoreObjectAccessorWithLock
java.lang.InterruptedException
java.util.concurrent.TimeoutException
public java.util.Date getLastModifiedDate()
PersistenceObjectStore.StoreObjectAccessor
getLastModifiedDate
in interface PersistenceObjectStore.StoreObjectAccessor
public java.util.concurrent.locks.ReadWriteLock getLockObject()
PersistenceObjectStore.StoreObjectAccessorWithLock
getLockObject
in interface PersistenceObjectStore.StoreObjectAccessorWithLock
public java.lang.String toString()
toString
in class java.lang.Object