public abstract class AbstractReadWriteAcces<P> extends Object implements IReadAccess<P>
IReadAccess.Priority<P>| Modifier and Type | Field and Description |
|---|---|
protected Lock |
readLock
This field should be
private. |
protected ReentrantReadWriteLock |
rwLock
This field should be
private. |
protected Lock |
writeLock
This field should be
private. |
| Constructor and Description |
|---|
AbstractReadWriteAcces() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterModify(P state,
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,
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 ReentrantReadWriteLock rwLock
private. It is protected for API compatibility only. Never access
this from the outside.protected final Lock writeLock
private. It is protected for API compatibility only. Never access
this from the outside.protected final 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, Object result, IUnitOfWork<?,P> work)
result - - delivered resultwork - - the unit of work to be processedprotected void afterReadOnly(P state, Object result, IUnitOfWork<?,P> work)
result - - delivered resultwork - - the unit of work to be processedprotected 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.Copyright © 2015. All Rights Reserved.