Declaring point-cut

Point-cuts are regular expressions or patterns to filter join-points where we want to apply advice. Since Spring AOP only supports method-level join-points, you can consider a point-cut as a matching of method execution on Spring beans. In the @AspectJ annotation style, a point-cut is declared by a method of an Aspect class (declared with the @Aspect annotation). Such methods are called point-cut signatures. The @Pointcut annotation is used to define such a method as follows:

@Aspectpublic class SessionCheck {  @Pointcut("execution( * com.packt.spring.aop.service.*.*(..))") // Expression  private void validateSession() {// Point-cut signature  }}

In this code, the validateSession method represents a point-cut signature, while ...

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.