org.nakedobjects.runtime.transaction
Class NakedObjectTransactionManagerAbstract<T extends NakedObjectTransaction>

java.lang.Object
  extended by org.nakedobjects.runtime.transaction.NakedObjectTransactionManagerAbstract<T>
All Implemented Interfaces:
Component, Injectable, SessionScopedComponent, NakedObjectTransactionManager
Direct Known Subclasses:
ObjectStoreTransactionManager

public abstract class NakedObjectTransactionManagerAbstract<T extends NakedObjectTransaction>
extends java.lang.Object
implements NakedObjectTransactionManager


Constructor Summary
NakedObjectTransactionManagerAbstract()
           
 
Method Summary
 void close()
           
protected  MessageBroker createMessageBroker()
          Overridable hook, used in {@link #createTransaction(MessageBroker, UpdateNotifier)
protected  T createTransaction()
          Creates a new transaction and saves, to be accessible in getTransaction().
protected abstract  T createTransaction(MessageBroker messageBroker, UpdateNotifier updateNotifier)
          Overridable hook.
protected  UpdateNotifier createUpdateNotifier()
          Overridable hook, used in {@link #createTransaction(MessageBroker, UpdateNotifier)
 void debugData(DebugString debug)
           
protected  void ensureTransactionInProgress()
           
protected  void ensureTransactionNotInProgress()
           
 void executeWithinTransaction(TransactionalClosure closure)
          Run the supplied block of code (closure) in a transaction.
<Q> Q
executeWithinTransaction(TransactionalClosureWithReturn<Q> closure)
          Run the supplied block of code (closure) in a transaction.
protected  MessageBroker getMessageBroker()
          Convenience method returning the MessageBroker of the current transaction.
 NakedObjectSession getSession()
          The owning NakedObjectSession.
 T getTransaction()
          Current transaction (if any).
protected  UpdateNotifier getUpdateNotifier()
          Convenience method returning the UpdateNotifier of the current transaction.
 void injectInto(java.lang.Object candidate)
           
 boolean inTransaction()
           
 void open()
           
 void setSession(NakedObjectSession session)
          Should be injected prior to opening
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nakedobjects.runtime.transaction.NakedObjectTransactionManager
abortTransaction, endTransaction, flushTransaction, startTransaction
 

Constructor Detail

NakedObjectTransactionManagerAbstract

public NakedObjectTransactionManagerAbstract()
Method Detail

open

public void open()
Specified by:
open in interface SessionScopedComponent

close

public void close()
Specified by:
close in interface SessionScopedComponent

getTransaction

public T getTransaction()
Current transaction (if any).

Specified by:
getTransaction in interface NakedObjectTransactionManager

getUpdateNotifier

protected UpdateNotifier getUpdateNotifier()
Convenience method returning the UpdateNotifier of the current transaction.


getMessageBroker

protected MessageBroker getMessageBroker()
Convenience method returning the MessageBroker of the current transaction.


executeWithinTransaction

public void executeWithinTransaction(TransactionalClosure closure)
Description copied from interface: NakedObjectTransactionManager
Run the supplied block of code (closure) in a transaction.

If a transaction is in progress, then uses that. Otherwise will start a transaction before running the block and commit it at the end. If the closure throws an exception, then will abort the transaction.

Specified by:
executeWithinTransaction in interface NakedObjectTransactionManager

executeWithinTransaction

public <Q> Q executeWithinTransaction(TransactionalClosureWithReturn<Q> closure)
Description copied from interface: NakedObjectTransactionManager
Run the supplied block of code (closure) in a transaction.

If a transaction is in progress, then uses that. Otherwise will start a transaction before running the block and commit it at the end. If the closure throws an exception, then will abort the transaction.

Specified by:
executeWithinTransaction in interface NakedObjectTransactionManager

inTransaction

public boolean inTransaction()

createTransaction

protected final T createTransaction()
Creates a new transaction and saves, to be accessible in getTransaction().


createTransaction

protected abstract T createTransaction(MessageBroker messageBroker,
                                       UpdateNotifier updateNotifier)
Overridable hook.

The provided MessageBroker and UpdateNotifier are obtained from the hook methods (createMessageBroker() and createUpdateNotifier()).

See Also:
createMessageBroker(), createUpdateNotifier()

createMessageBroker

protected MessageBroker createMessageBroker()
Overridable hook, used in #createTransaction(MessageBroker, UpdateNotifier)

Called when a new {@link NakedObjectTransaction} is created.


createUpdateNotifier

protected UpdateNotifier createUpdateNotifier()
Overridable hook, used in #createTransaction(MessageBroker, UpdateNotifier)

Called when a new {@link NakedObjectTransaction} is created.


ensureTransactionInProgress

protected void ensureTransactionInProgress()

ensureTransactionNotInProgress

protected void ensureTransactionNotInProgress()

injectInto

public void injectInto(java.lang.Object candidate)
Specified by:
injectInto in interface Injectable

debugData

public void debugData(DebugString debug)
Specified by:
debugData in interface NakedObjectTransactionManager

getSession

public NakedObjectSession getSession()
Description copied from interface: NakedObjectTransactionManager
The owning NakedObjectSession.

Will be non-null when opened, but null if closed .

Specified by:
getSession in interface NakedObjectTransactionManager

setSession

public void setSession(NakedObjectSession session)
Should be injected prior to opening



Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.