Declaring advices:-
Advice is associated with a pointcut expression, and runs before, after, or
around method executions matched by the pointcut. The pointcut expression may be
either a simple reference to a named pointcut, or a pointcut expression declared
in place.You can declare any of the five advices using @{ADVICE-NAME}
annotations.
1 Before advice
Before advice is declared in an aspect using the @Before annotation:
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
@Aspect
public class BeforeExample {
@Before("execution(* com.xyz.myapp.service.(..))")
public void logRequiredTask() {
// ...
}}