Professional Documents
Culture Documents
Aspect-Oriented Software
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
Development
Bruno Harbulot
ESNW, the University of Manchester
http://www.cs.man.ac.uk/~harbulob/
Problem: code-tangling
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
2/24
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
3/24
Problem presentation
good modularity
URL pattern matching
Source: http://www.eclipse.org/aspectj/teaching.php
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
4/24
problems like… logging is not modularized
Source: http://www.eclipse.org/aspectj/teaching.php
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
●
logging in org.apache.tomcat
– red shows lines of code that handle logging
– not in just one place
– not even in a small number of places
(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.
5/24
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
6/24
of
Concepts
Programming
Aspect-Oriented
Crosscutting concerns
crosscutting concerns.
●
Encapsulate crosscutting concerns into
aspects.
8/24
Concepts of AOP (I)
●
Join point: point in the execution of a program
where an aspect might intervene.
●
“[...] whenever condition C arises, perform action
A” [Fil05]
– Pointcut: expression of a subset of join points
(condition C)
– Advice: piece of code for action A.
– Pointcuts and advice encapsulated into aspects.
9/24
Concepts of AOP (II)
10/24
Concepts of AOP (III)
Weaving
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
Base units
Weaver Application
Aspects
11/24
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
12/24
Tools
Programming
Aspect-Oriented
AOP Tools
(Java-based tools)
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
● Languages:
– AspectJ (now merged with AspectWerkz)
● Frameworks (mainly for J2EE applications):
– JAC
– Jboss AOP
13/24
AspectJ
14/24
AspectJ example: pre-condition
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
/* Java code */
class Test {
public int val ;
/* ... */
}
15/24
AspectJ example: persistence
aspect DatabaseAspect {
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
before(): transactionalMethods () {
initialiseDatabase() ;
}
16/24
AspectJ – Pointcuts
17/24
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
18/24
Application:
Design patterns
Observer pattern (I)
19/24
Observer pattern (II)
20/24
Bruno Harbulot – ELF Developers' Forum – Manchester - 19/10/05
21/24
Conclusions
Benefits and pitfalls
(more reusability)
● Pitfalls:
– Learning curve to comprehend the concepts
(eased by Java environment)
– Need for tools to understand the overall
behaviour of the application (Eclipse AJDT)
http://www.eclipse.org/ajdt/
(available for other IDEs as well)
22/24
References (I)
●
AspectJ: http://www.eclipse.org/aspectj/
●
“Foundations of AOP for J2EE Development”
by R. Pawlak et al., ISBN: 1590595076
●
“Eclipse AspectJ” by A. Colyer et al.,
ISBN: 0321245873
●
[Lad03] “AspectJ in Action” by R. Laddad,
ISBN: 1930110936
●
[Fil05] “Aspect-Oriented Software Development” by R.
Filman et al., ISBN: 0321219767
23/24
References (II)
24/24