Master of Computer Science - University of Grenoble


Aspect-Oriented Programming / AspectJ

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


TP 2 : Logging

1. Objective

Design and implement application logging 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. Banking application

Download the application code.

The banking application is available in Project/TP2/Basic:

Compile and run the application:

4. Description of work

(a) Logging methods

As an example, Project/TP2/Logging_HandCoded/1_Methods contains a "hand-coded" version of the banking application extended with logging features using the Java standard library java.util.logging.

Implement method logging using AspectJ in the Project/TP2/Logging_Aspects directory, by writing an aspect in Project/TP2/Logging_Aspects/aspects/logging/LogAspect.java:

(b) Logging exceptions

Implement exception logging using AspectJ in the Project/TP2/Logging_Aspects directory, by writing an aspect in Project/TP2/Logging_Aspects/aspects/logging/LogAspect.java

(c) Logging method parameters

Implement method parameter logging using AspectJ in Project/TP2/Logging_Aspects, by writing an aspect in Project/TP2/Logging_Aspects/aspects/logging/LogAspect.java

Use AspectJ constructs like thisJoinPoint and thisJoinPointStaticPart.

(d) Use another logging library

Other Java librairies implement logging, such as log4j (http://logging.apache.org/log4j/).

Main logging methods for log4j are:

API of the two logging systems:

    1- Modify the banking application to use log4j logging library

Modify the hand-coded implementation of the application  in Project/TP2/Logging_HandCoded/ in order to use log4j library.

log4j.jar library is available in Project/TP2/Logging_HandCoded/4_MethodsExceptionsParametersLog4j/lib/

    2- Modify the AspectJ aspect to use log4j logging library

Modify the aspect implementation in Project/TP2/Logging_Aspects/aspects/logging/LogAspect.java in order to use log4j library.

log4j.jar library is available in Project/TP2/Logging_Aspects/lib/

    3- Compare the impact of the two previous modifications from a programmer point of view