Pointcut declarations and pointcut Expressions


Pointcut Declarations:

A pointcut declaration includes a signature that includes a word with any parameters and a pointcut expression that specifies which action we want to view.

Pointcut Expression:

A pointcut expression specifies which base system and advises joinpoint executions should be used.
We'll also examine how the API representing a matched joinpoint during advice execution relates to pointcut expression constructions.

Spring AOP – Pointcut Expressions

A pointcut is a set of joint points that define where advice should be applied.

In other terms, a pointcut is a collection of different join points.
"Where advice should be carried out," it says. Let's look at an example of how to utilize pointcut.

Assume there are numerous join points in the system where aspects should be applied.
We may use pointcut expression instead of applying aspects to each join point.

The @Pointcut annotation is used to declare a pointcut. It's in the org.AspectJ.lang. Annotation package.
Package of pointcuts.

There are two elements to a pointcut declaration:

  • Pointcut Expression: Pointcut Expression is the value of the @Pointcut annotation.
  • Pointcut Signature: The @Pointcut-annotated technique is referred to as Pointcut Signature.
  • Pointcut Expressions
    • Let's look at a few pointcut expressions to comprehend them better.
    • We need to have some knowledge of Wildcards before learning about Pointcut Expressions.
    • AspectJ employs wildcards to construct pointcuts to capture connect points that share similar features.
    • In pointcuts, there are two sorts of wildcards:
  • Except for the period, the (*) wildcard can represent any number of characters. It's also used to define the portion of a class, interface, or package name in a type signature pattern.
  • The wildcard (..) can represent any number of characters, including periods. It also refers to all sub-packages, both direct and indirect.