-
Introducción
- Programación Orientada a Aspectos
- Complemento de Programación Orientada a Objetos
- Aspecto: responsabilidad que cruza multiples clases
-
Ejemplos
- Transaccionabilidad
- Auditoría
- Seguridad
-
Conceptos
-
Aspect
- modularization of a concern that cuts across multiple classes
-
Join point
- a point during the execution of a program
- method execution
-
Advice
- action taken by an aspect at a particular join point
- around, after, before, etc
-
Pointcut
- a predicate that matches join points
- AspectJ pointcut EL
-
Introduction
- declaring additional methods or fields on behalf of a type
-
Target object
- object being advised by one or more aspects
- en Spring AOP son runtime proxies
-
AOP proxy
- an object created by the AOP framework in order to implement the aspect contracts
- JDK dynamic proxy
- CGLIB proxy
-
Weaving
- compile time
- load time
- runtime
-
SpringAOP
- Implementado en Java puro
- Puede ser utilizado en un contenedor web o en un application server
- No es una implementación AOP completa
-
@AspectJ
- <aop:aspectj-autoproxy/>
- @Aspect
-
@Pointcut
- @Pointcut("execution(* transfer(..))")
-
pointcut designators
- execution
- within
- this
- target
- args
- bean(idOrNameOfBean)
-
Advice
-
Tipos
- @Before
- @AfterReturning
- @AfterThrowing
- @After
- @Around
-
Advice parameters
- Access to the current JoinPoint
- Passing parameters to advice
- Solo para métodos públicos
-
Schema-based
- <aop:config>
- <aop:aspect id="myAspect" ref="aBean">
- <aop:pointcut id="businessService"
expression="execution(* com.xyz.myapp.service.*.*(..))"/>
-
Acerca de
- Topic
- Topic