|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ProgrammaticRef<E>
The ProgrammaticRef is a managed reference specially made for projects that don't want to rely on instrumentation, but do want to have managed references.
It provides a lot of methods and I don't think that exposing this method is very wise. I would expect that some nice language sugar is added on top. If you also want to coordinate transactions without relying on instrumentation, you need to have a look at theTransactionTemplate
This ProgrammaticRef exposes in a lot of cases 3 types of methods:
| Method Summary | |
|---|---|
boolean |
atomicCompareAndSet(E expected,
E update)
Executes a compare and swap without looking at a running transaction. |
E |
atomicGet()
Gets the value without looking at an existing transaction (it will run its 'own'). |
boolean |
atomicIsNull()
Checks if the value stored in this reference is null. |
E |
atomicSet(E newValue)
Sets the new value on this ProgrammaticRef using its own transaction (so it doesn't look at an existing transaction). |
E |
get()
Gets the value. |
E |
get(Transaction tx)
Gets the value using the specified transaction. |
E |
getOrAwait()
|
E |
getOrAwait(Transaction tx)
|
E |
getOrAwait(TransactionFactory txFactory)
|
boolean |
isNull()
Checks if the value stored in this reference is null. |
boolean |
isNull(Transaction tx)
Checks if the value stored in this reference is null using the provided transaction. |
E |
set(E newValue)
Sets the new value on this reference. |
E |
set(Transaction tx,
E newValue)
Sets the new value on this reference using the provided transaction. |
String |
toString(Transaction tx)
|
| Method Detail |
|---|
E get()
atomicGet() is used. In that cases it will be very very cheap (roughly
2/3 of the performance of atomicGet(). The reason why this call is more expensive
than the atomicGet() is that a getThreadlocalTransaction needs to be called and
a check on the Transaction if that is running.
IllegalThreadStateException - if the current transaction isn't in the right state
for this operation.
ControlFlowErrorE get(Transaction tx)
tx - the Transaction used for reading the value.
NullPointerException - if tx is null
IllegalTransactionStateException - if the transaction is not
in the correct state for this operation.
ControlFlowErrorE atomicGet()
AtomicReference.get(). To be more specific;
it would have the same performance as AtomicReferenceFieldUpdater.get(Object)
since that is used under water.
ReadConflict - if something fails while loading the reference.E set(E newValue)
atomicSet(Object) is used
(which is very fast).
newValue - the new value to be stored in this reference. The newValue is allowed to
be null.
WriteConflict - if something failed while committing. If the commit fails, nothing bad will happen.
ReadConflict - if something fails while loading the reference.
IllegalThreadStateException - if the transaction was not in the correct state for
this operations. If the transaction in the TransactionThreadLocal is dead (so aborted or
committed), a new transaction will be used.
E set(Transaction tx,
E newValue)
set(Object).
tx - the transaction to use.newValue - the new value, and is allowed to be null.
IllegalTransactionStateException - if the transaction isn't in the correct state for this operation.
ReadConflict - if something fails while loading the reference.
NullPointerException - if tx is nullE atomicSet(E newValue)
atomicCompareAndSet(Object, Object)
newValue - the new value.
WriteConflict - if something failed while committing. If the commit fails, nothing bad will happen.
ReadConflict - if something fails while loading the reference.
boolean atomicCompareAndSet(E expected,
E update)
expected - the expected valueupdate - the update
boolean isNull()
get() for more info since
that method is used to retrieve the current value.
ReadConflict - if something fails while loading the reference.boolean isNull(Transaction tx)
tx - the transaction used
NullPointerException - if tx is null.
DeadTransactionException - is tx isn't active
ReadConflict - if something fails while loading the reference.boolean atomicIsNull()
atomicGet() for more information.
ReadConflict - if something fails while loading the reference.E getOrAwait()
E getOrAwait(TransactionFactory txFactory)
E getOrAwait(Transaction tx)
tx -
NullPointerException - if tx is nullString toString(Transaction tx)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||