Advice
Prev | Appendix A. AspectJ Quick Reference | Next

## Advice

Each piece of advice is of the form

> `[ strictfp ] `AdviceSpec` [ throws `TypeList` ] : `Pointcut` { `Body` }`

where `AdviceSpec` is one of

`before( `Formals` )`
  runs before each join point
`after( `Formals` ) returning [ ( `Formal` ) ]`
  runs after each join point that returns normally. The optional formal gives access to the returned value
`after( `Formals` ) throwing [ ( `Formal` ) ]`
  runs after each join point that throws a `Throwable`. If the optional formal is present, runs only after each join point that throws a `Throwable` of the type of `Formal`, and `Formal` gives access to the `Throwable` exception value
`after( `Formals` )`
  runs after each join point regardless of whether it returns normally or throws a `Throwable`
``Type` around( `Formals` )`
  runs in place of each join point. The join point can be executed by calling `proceed`, which takes the same number and types of arguments as the around advice.

Three special variables are available inside of advice bodies:

`thisJoinPoint`
  an object of type `org.aspectj.lang.JoinPoint` representing the join point at which the advice is executing.
`thisJoinPointStaticPart`
  equivalent to `thisJoinPoint.getStaticPart()`, but may use fewer runtime resources.
`thisEnclosingJoinPointStaticPart`
  the static part of the dynamically enclosing join point.

Prev | Up | Next
Type Patterns | Home | Inter-type member declarations