Master of Computer Science - University of Grenoble
Contact: Sara Bouchenak, Sara.Bouchenak@imag.fr
Design and implement application logging with AOP/AspectJ.
If not already installed, install the following software:
Java 2 SDK
AspectJ
Ant
IDE (e.g. Eclipse)
If not already defined, define the following environment variables:
JAVA_HOME
ASPECTJ_HOME
ANT_HOME
PATH (inclut JAVA_HOME/bin, ASPECTJ_HOME/bin, ANT_HOME/bin)
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).
Download the application code.
The banking application is available in Project/TP2/Basic:
Project/TP2/Basic/docs/api/index.html provides the API documentation of the application.
Project/TP2/Basic/src contains the source code of the application.
Compile and run the application:
Compilation: ant compile
Execution: ant run
Global build: ant all
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:
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
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.
Other Java librairies implement logging, such as log4j (http://logging.apache.org/log4j/).
Main logging methods for log4j are:
Method org.apache.log4j.Logger.info(message)
Method org.apache.log4j.Logger.warn(message)
Log4j uses the log4j.properties configuration file.
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