dans une application (sécurité, notification...).
Spring AOP est un support parfaitement adapté à la création et l'intégration des éléments constitutifs d'une POA tels que les aspects, les coupes, les greffons.
Spring AOP plus détail :
La portée de l’interception porte sur les beans gérés par le conteneur.
· Utilisation de Spring AOP classique
o Définition d’un Advisor avec 4 implémentations de l’interface PointCut
1. DefaultPointCutAdvisor
2. NameMatchMethodPointCutAdvisor
3. RegexpMethodPointCutAdvisor
4. AspectJExpressionPointCutAdvisor
o Définition d’un greffon avec 4 interfaces
1. MethodInterceptor (greffon de type around)
2. MethodBeforeAdice (greffon de type before)
3. AfterReturningAdvice (greffon de type after returning)
4. ThrowsAdvice (greffon de type after throwing)
· Utilisation de Spring AOP avec AspectJ
o Définition d’un aspect avec 2 formats de définition :
1. Format xml : <aop :config><aop:aspect><aop:pointcut id=’coupe’ expression=’execution(synthaxe aspect)’ />
· <aop:around>
· <aop:before>
· <aop:after>
· <aop:after-returning>
· <aop:after-throwing>
2. Annotations Java5 avec activation <aop :aspectj-autoproxy/>
· @Aspect
· @Around
· @Before
· @After
· @AfterReturning
· @AfterThrowing
3. Introspection de la méthode interceptée
· Utilisation d’un JoinPoint ou dérivé (ProceedingJoinPoint) pour :
o getSignature().getName()
o getThis()
o getTarget()
o getArgs()
· Typage de la coupe : récupération des informations de la méthode de manière fortement typée. Spécification des paramètres dans la coupe et au niveau du greffon :
o this
o target
o args
o returning
o throwing
· Le mécanisme d’introduction
· Le tissage des aspects
· Modification de cibles