Package com.googlecode.objectify.impl
Class TransactorYes<O extends Objectify>
- java.lang.Object
-
- com.googlecode.objectify.impl.Transactor<O>
-
- com.googlecode.objectify.impl.TransactorYes<O>
-
public class TransactorYes<O extends Objectify> extends Transactor<O>
Implementation for when we start a transaction. Maintains a separate session, but then copies all data into the original session on successful commit.- Author:
- Jeff Schnitzer
-
-
Field Summary
Fields Modifier and Type Field Description protected TransactorNo<O>
parentTransactor
The non-transactional transactor that spawned usprotected Result<TransactionImpl>
transaction
Our transaction.-
Fields inherited from class com.googlecode.objectify.impl.Transactor
deferrer, session
-
-
Constructor Summary
Constructors Constructor Description TransactorYes(ObjectifyImpl<O> current, TransactorNo<O> parentTransactor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
committed()
Called when the associated transaction is committed.<R> R
execute(ObjectifyImpl<O> parent, TxnType txnType, Work<R> work)
TransactionImpl
getTransaction()
<R> R
transact(ObjectifyImpl<O> parent, Work<R> work)
ObjectifyImpl<O>
transactionless(ObjectifyImpl<O> parent)
This version goes back to life without a transaction, but preserves current state regarding deadline, consistency, etc.<R> R
transactNew(ObjectifyImpl<O> parent, int limitTries, Work<R> work)
We need to make sure the parentSession is the transactionless session, not the session for our transaction.-
Methods inherited from class com.googlecode.objectify.impl.Transactor
getDeferrer, getSession
-
-
-
-
Field Detail
-
transaction
protected Result<TransactionImpl> transaction
Our transaction.
-
parentTransactor
protected TransactorNo<O extends Objectify> parentTransactor
The non-transactional transactor that spawned us
-
-
Constructor Detail
-
TransactorYes
public TransactorYes(ObjectifyImpl<O> current, TransactorNo<O> parentTransactor)
-
-
Method Detail
-
getTransaction
public TransactionImpl getTransaction()
- Specified by:
getTransaction
in classTransactor<O extends Objectify>
- Returns:
- the transaction appropriate to this transaction state, or null if there is no transaction.
-
transactionless
public ObjectifyImpl<O> transactionless(ObjectifyImpl<O> parent)
This version goes back to life without a transaction, but preserves current state regarding deadline, consistency, etc. We use the session from the parent, ie life before transactions.- Specified by:
transactionless
in classTransactor<O extends Objectify>
- Parameters:
parent
- is the parent objectify instance; the one being transitioned from- Returns:
- an Objectify instance that is suitable for transactionless execution. In the case of a transactor which is not in a transaction, probably this is the same as getObjectify().
-
execute
public <R> R execute(ObjectifyImpl<O> parent, TxnType txnType, Work<R> work)
- Specified by:
execute
in classTransactor<O extends Objectify>
- See Also:
Objectify.execute(TxnType, Work)
-
transact
public <R> R transact(ObjectifyImpl<O> parent, Work<R> work)
- Specified by:
transact
in classTransactor<O extends Objectify>
- See Also:
Objectify.transact(Work)
-
transactNew
public <R> R transactNew(ObjectifyImpl<O> parent, int limitTries, Work<R> work)
We need to make sure the parentSession is the transactionless session, not the session for our transaction. This gives proper transaction isolation.- Specified by:
transactNew
in classTransactor<O extends Objectify>
- See Also:
Objectify.transactNew(int, Work)
-
committed
public void committed()
Called when the associated transaction is committed. Dumps the contents of the transactional session into the parent's session.
-
-