Provides an aspect that allows to define methods that will be executed transactionaly.

A transaction is either performed completely or its effects are erased. In the former case, we say that the transaction is committed. In the latter case, the transaction is said to be rollbacked. A transaction is used when a critical computation comes into play, and that one wants to have guarantees on the state of the application if the computation fails. Transactions guarantee that in such a case, the state of the application prior to the begining of the transaction will be restored. Properties in term of isolation between concurrent transactions are also provided: basically, the effects (data updates) of a transaction are not made visible to the other transactions, before the former one commits. A transaction works on persistent data, i.e. data saved in a DBMS. Other non persistent data (object fields, local variables) are not affected by the transaction.

This aspect encapsulates the ObjectWeb JOTM transaction monitor. Whereas standard JDBC connections also provide transactional properties, the added value of JOTM is to enable transactions that span other several distributed JDBC-accessible DBMS. This aspect requires the org.objectweb.jac.aspects.distrans-persistence.PersistenceAC that defines which persistent data must be involved in the transaction.

This AC defines an unique configuration method (delimitTransaction) that gives two pointcuts and a decision procedure. The join points associated with the two pointcuts demark the begining and the end of the transaction. Most of the time, a single method is concerned (such as in the example below), and hence the transaction starts at the beginning of the method and ends when the method returns. Nevertheless, any other execution flow designated by two JAC pointcuts can be associated with a transaction. The decision procedure says whether the transaction must be commited or rollbacked. This must be a subclass of the abstract class org.objectweb.jac.aspects.distrans.EndTransactionWrapper that implements the decide method. The typical usage scenario of this AC is illustrated below (the example can also be found in the org.objectweb.jac.samples.distransbank application).

/**
 * Delimit the transaction t0.
 * It begins before Account#transfert().
 * It ends after Account#transfert().
 * The last parameter (jac.samples.distransbank.SampleEndTransactionWrapper)
 * is the name of the class defining the method for deciding whether the
 * transaction is to be commited or rollbacked.
 */
delimitTransaction t0 Account ".*" "transfert.*" Account ".*" "transfert.*" SampleEndTransactionWrapper;

Related Documentation

For overviews, sources, tutorials, examples, guides, and tool documentation, please see: