Master of Computer Science - University of Grenoble


Aspect-Oriented Programming / AspectJ

Contact : Sara Bouchenak, Sara.Bouchenak@imag.fr


TP 3: Dependability

1. Objective

Design and implement transactions with AOP/AspectJ.

2. Software environment

If not already installed, install the following software:

If not already defined, define the following environment variables:

Examples for defining such variables are given in the file named env-tcsh for Unix/tcsh (run: source env-tcsh), and in the file named env-win.bat for Windows (run: env-win.bat).

3. Original banking application

Download the application code.

The banking application is available in TP3/Basic/:

Configure the database:

Compile and run the application:

4. Hand-coded dependability of banking application

As an example, TP3/Transactions_HandCoded/ contains a "hand-coded" version of the banking application extended with dependability and transaction features:

  1. Database connection auto-commit mode is deactivated by the calling setAutoCommit(false) method on banking.DatabaseImpl.getConnection.   
     
  2. Multiple database queries inside the same transaction are executed within the same database connection.   
    See new versions of methods debit, credit, getBalance and setBalance in banking.DatabaseAccountImpl class, and new versions of methods query and  update in banking.DatabaseImpl class.   
     
  3. Commit/abort a transaction.    
    See new version of method banking.InterAccountOperations.transfer.

The hand-coded version of the application is organized as follows:

Compile and run the application:

5. Description of work

Implement transactions using AspectJ in the TP3/Transactions_Aspects/ directory, by writing an aspect in TP3/Transactions_Aspects/aspects/transactions/TransAspect.java

The AspectJ-based solution should provide the following:

  1. Use the same java.sql.Connection object for queries within the same transaction: use AspectJ percflow.   
     
  2. Deactivate auto-commit when creating a new database connection by calling setAutoCommit(false).   
     

  3. If nested operations, commit/rollback on highest-level operation: use AspectJ percflowbelow.

To compile and run the application:

5. Combine aspects

Combine the Logging aspect implemented in TP2, Dependability aspect implemented in TP3 and Security aspect implemented in TP4, and automatically include all to the banking application.

Do not modify the aspects' code, neither the application code.