Terminology

Learn about a few basic concepts of AOP.

Aspect

An aspect is a Java class that implements cross-cutting concerns. The @Aspect annotation is used to define a class as an aspect. An aspect is a combination of the kinds of methods to intercept and what to do after intercepting them.

Aspects can define functionality for any concern like logging, performance management, or transaction management that cuts across multiple application layers.

Pointcut

Pointcuts are expressions that determine which method calls will be intercepted. These expressions determine whether an advice needs to be executed or not. Pointcuts are defined following a particular syntax.

Pointcuts should be carefully defined, as they determine how many calls will be intercepted.

Advice

The tasks performed after intercepting a method call are called advice. It is the logic of the methods in a class marked with @Aspect. Advices are basically the methods that get executed when a method calls meets a pointcut. These methods can get executed before, around the time of, or after the execution of the intercepted method call. There are different advice types as shown below.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.