learning the Spring AOP, the code like this:
@Component
@Aspect
public class FanAnnotationImpl {
@Pointcut("@annotation(com.fan.spboot.core.aopdemo.FanAnnotation)")
private void entry(){
System.out.println("entry annotation");
}
@Around("entry()")
public void around(ProceedingJoinPoint joinPoint)throws Throwable{
System.out.println("around before");
try {
joinPoint.proceed();
}catch (Exception e){
e.printStackTrace();
}
System.out.println("around after");
}
@Before("entry()")
public void before(){
System.out.println("Before entry");
}
@After("entry()")
public void after(){
System.out.println("After entry");
}
}
the spring-aop-pointcut-tutorial has a introduction:
"The method declaration is called the pointcut signature. It provides a name that can be used by advice annotations to refer to that pointcut."
What make me feel puzzled is the method use @Pointcut ,it's just a pointcut signature? Because I find the code in this method not executed, and change the type of this method is OK; Then why is a method? Use a variable is also OK?