Java Reference
In-Depth Information
package com.apress.springenterpriserecipes.calculator;
public class ArithmeticCalculatorImpl implements ArithmeticCalculator {
@LoggingRequired
public double add(double a, double b) {
...
}
@LoggingRequired
public double sub(double a, double b) {
...
}
@LoggingRequired
public double mul(double a, double b) {
...
}
@LoggingRequired
public double div(double a, double b) {
...
}
}
Now you can write a pointcut expression to match all methods with this @LoggingRequired
annotation.
@annotation(com.apress.springenterpriserecipes.calculator.LoggingRequired)
Type Signature Patterns
Another kind of pointcut expressions matches all join points within certain types. When applied to
Spring AOP, the scope of these pointcuts will be narrowed to matching all method executions within
the types. For example, the following pointcut matches all the method execution join points within the
com.apress.springenterpriserecipes.calculator package:
within(com.apress.springenterpriserecipes.calculator.*)
To match the join points within a package and its subpackage, you have to add one more dot before
the wildcard.
within(com.apress.springenterpriserecipes.calculator..*)
The following pointcut expression matches the method execution join points within a
particular class:
within(com.apress.springenterpriserecipes.calculator.ArithmeticCalculatorImpl)
Again, if the target class is located in the same package as this aspect, the package name can be
omitted.
within(ArithmeticCalculatorImpl)
Search WWH ::




Custom Search