|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.multiverse.templates.TransactionBoilerplate
public final class TransactionBoilerplate
TransactionBoilerplate contains the boilerplate logic to deal with transaction and needs to be used in combination with the TransactionalCallable.
example:new TransactionLogic().execute(new TransactionalCallableTransactionLogic is threadsafe and is designed to be reused. In case of transactional actors, you can create a TransactionLogic object per class of actors (so static field) or per actor (instance field).{ Integer call(){ return queue.pop(); } }).execute();
| Field Summary |
|---|
| Fields inherited from interface org.multiverse.MultiverseConstants |
|---|
___BUGSHAKER_ENABLED, ___TRACING_ENABLED |
| Constructor Summary | |
|---|---|
TransactionBoilerplate()
Creates a new TransactionLogic that uses the STM stored in the GlobalStmInstance and works the the ThreadLocalTransaction. |
|
TransactionBoilerplate(Stm stm)
Creates a new TransactionLogic using the provided STM. |
|
TransactionBoilerplate(TransactionFactory transactionFactory)
Creates a new TransactionLogic with the provided TransactionFactory and that is aware of the ThreadLocalTransaction. |
|
TransactionBoilerplate(TransactionFactory transactionFactory,
TransactionLifecycleListener listener,
boolean threadLocalAware)
Creates a new TransactionLogic with the provided TransactionFactory. |
|
| Method Summary | ||
|---|---|---|
|
execute(TransactionalCallable<E> callable)
Executes the TransactionalCallable. |
|
|
executeChecked(TransactionalCallable<E> callable)
Executes the Template. |
|
TransactionFactory |
getTransactionFactory()
Returns the TransactionFactory this TransactionLogic uses to createReference Transactions. |
|
TransactionLifecycleListener |
getTransactionLifecycleListener()
Returns the TransactionLifecycleListener |
|
boolean |
isThreadLocalAware()
Checks if the TransactionLogic should work together with the ThreadLocalTransaction. |
|
protected void |
onStart(Transaction tx)
Lifecycle method that is called every time the transaction is started. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TransactionBoilerplate()
ThreadLocalTransaction. It automatically creates update transactions that are able to track
reads.
This constructor should only be used for experimentation purposes. If you want something fast, you need to pass
in a TransactionFactory.
public TransactionBoilerplate(Stm stm)
ThreadLocalTransaction.
It automatically creates read tracking update transactions.
This constructor should only be used for experimentation purposes. If you want something fast, you need to pass
in a TransactionFactory.
stm - the stm to use for transactions.
java.lang.NullPointerException - if stm is null.public TransactionBoilerplate(TransactionFactory transactionFactory)
transactionFactory - the TransactionFactory used to createReference Transactions.
java.lang.NullPointerException - if txFactory is null.
public TransactionBoilerplate(TransactionFactory transactionFactory,
TransactionLifecycleListener listener,
boolean threadLocalAware)
transactionFactory - the TransactionFactory used to createReference Transactions.threadLocalAware - true if this TransactionLogic should look at the ThreadLocalTransaction
and publish the running transaction there.
todolistener - true if the lifecycle callback methods should be enabled. Enabling them causes
extra object creation, so if you want to squeeze out more performance, set
this to false at the price of not having the lifecycle methods working.| Method Detail |
|---|
public boolean isThreadLocalAware()
public TransactionLifecycleListener getTransactionLifecycleListener()
TransactionLifecycleListener
public TransactionFactory getTransactionFactory()
protected void onStart(Transaction tx)
tx - the Transaction that is started.public <E> E execute(TransactionalCallable<E> callable)
InvisibleCheckedException.
callable - the TransactionalCallable to execute.
InvisibleCheckedException - if a checked exception was thrown while executing the callable.
DeadTransactionException - if the exception was explicitly aborted.
TooManyRetriesException - if the template retried the transaction too many times. The cause of the last
failure (also an exception) is included as cause. So you have some idea where
to look for problems
java.lang.NullPointerException - if callable is null.
public <E> E executeChecked(TransactionalCallable<E> callable)
throws java.lang.Exception
callable - the callable to execute.
DeadTransactionException - if the exception was explicitly aborted.
TooManyRetriesException - if the template retried the transaction too many times. The cause of the last
failure (also an exception) is included as cause. So you have some idea where to
look for problems
java.lang.NullPointerException - if callable is null.
java.lang.Exception - if the callable throws an exception.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||