Programmation par Aspect
(AOP)
Frédéric Fondement
Cours ENSISA 3AIR
2009-2010
© F. Fondement-2-
Le but du jour
En savoir plus sur les aspects
zRéflexion
zAnnotations
© F. Fondement-3-
La réflexion
Java possède son mécanisme de réflexion.
AspectJ
également
zDans un advice: thisJoinPoint
Le contexte: getTarget(), getThis(), getArgs()
Lent !
Préférer systématiquement les sélecteurs de contexte
Fil d’exécution: thisJoinPointStaticPart
thisJoinPoint.getStaticPart() ==
thisJoinPointStaticPart
getKind() : method-execution, constructor-call, field-get,…
getSignature() : informations sur la nature du join
point
getSourceLocation() : information sur l’endroit du join
point
Fichier (.java ou .aj)
Numéro de ligne
© F. Fondement-4-
API Réflective d’AspectJ
JoinPoin
t
Ob
j
ect
Signature
name : EString
toString() : EString
JoinPointStaticPart
kind : EString
toString() : EString
SourceLocation
fileName : EString
line : EIn
t
Class
thisJoinPoin
t
thisJoinPoinStaticPart
thisEnclosingJoinPointStaticPar
t
args0..*
signature
1
staticPart
1
location 1
class 1
withinType
1
tar
g
et0..1
this0..1
Conceptuel
© F. Fondement-5-
thisJoinPointStaticPart.getKind()
org.aspectj.lang.JoinPoint
public static final java.lang.String ADVICE_EXECUTION "adviceexecution"
public static final java.lang.String CONSTRUCTOR_CALL "constructor-call"
public static final java.lang.String CONSTRUCTOR_EXECU
TION
"constructor-
execution"
public static final java.lang.String EXCEPTION_HANDLER "exception-handler"
public static final java.lang.String FIELD_GET "field-get"
public static final java.lang.String FIELD_SET "field-set"
public static final java.lang.String INITIALIZATION "initialization"
public static final java.lang.String METHOD_CALL "method-call"
public static final java.lang.String METHOD_EXECUTION "method-execution"
public static final java.lang.String PREINTIALIZATION "preinitialization"
public static final java.lang.String STATICINITIALIZATION "staticinitialization"
1 / 15 100%
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !