public abstract class AbstractReadWriteAcces<P> extends java.lang.Object implements IReadAccess<P>
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.locks.Lock |
readLock
This field should be
private . |
protected java.util.concurrent.locks.ReentrantReadWriteLock |
rwLock
This field should be
private . |
protected java.util.concurrent.locks.Lock |
writeLock
This field should be
private . |
Constructor and Description |
---|
AbstractReadWriteAcces() |
Modifier and Type | Method and Description |
---|---|
protected void |
afterModify(P state,
java.lang.Object result,
IUnitOfWork<?,P> work)
is executed within the transaction right after the unit of work has been executed and delivered the result.
|
protected void |
afterReadOnly(P state,
java.lang.Object result,
IUnitOfWork<?,P> work)
is executed within the transaction right after the unit of work has been executed and delivered the result.
|
protected void |
beforeModify(P state,
IUnitOfWork<?,P> work)
Is called before a write lock is obtained
|
protected void |
beforeReadOnly(P state,
IUnitOfWork<?,P> work)
is called before a read lock is obtained
|
protected int |
getReadHoldCount()
Queries the number of reentrant read holds on this lock by the current thread.
|
protected abstract P |
getState() |
protected int |
getWriteHoldCount()
Queries the number of reentrant write holds on this lock by the current thread.
|
<T> T |
modify(IUnitOfWork<T,P> work) |
<T> T |
process(IUnitOfWork<T,P> work)
Upgrades a read transaction to a write transaction, executes the work then downgrades to a read transaction
again.
|
<T> T |
readOnly(IUnitOfWork<T,P> work) |
protected final java.util.concurrent.locks.ReentrantReadWriteLock rwLock
private
. It is protected
for API compatibility only. Never access
this from the outside.protected final java.util.concurrent.locks.Lock writeLock
private
. It is protected
for API compatibility only. Never access
this from the outside.protected final java.util.concurrent.locks.Lock readLock
private
. It is protected
for API compatibility only. Never access
this from the outside.protected abstract P getState()
public <T> T readOnly(IUnitOfWork<T,P> work)
readOnly
in interface IReadAccess<P>
public <T> T modify(IUnitOfWork<T,P> work)
public <T> T process(IUnitOfWork<T,P> work)
protected void beforeModify(P state, IUnitOfWork<?,P> work)
work
- - the unit of work to be processedprotected void beforeReadOnly(P state, IUnitOfWork<?,P> work)
work
- - the unit of work to be processedprotected void afterModify(P state, java.lang.Object result, IUnitOfWork<?,P> work)
result
- work
- protected void afterReadOnly(P state, java.lang.Object result, IUnitOfWork<?,P> work)
result
- work
- protected int getWriteHoldCount()
ReentrantReadWriteLock.getWriteHoldCount()
.protected int getReadHoldCount()
ReentrantReadWriteLock
as well, but not before version 1.6. This is
why we have to find our own way to work around it.