任何人都可以告诉我Joinpoint
和Proceedingjoinpoint
有何区别?使用aspectJ在AOP中的Joinpoint VS ProceedingJoinPoint?
何时使用Joinpoint
和Proceedingjoinpoint
在方面类的方法?
我曾经在我的JoinPoint
像AspectJ class
,
@Pointcut("execution(* com.pointel.aop.test1.AopTest.beforeAspect(..))")
public void adviceChild(){}
@Before("adviceChild()")
public void beforeAdvicing(JoinPoint joinPoint /*,ProceedingJoinPoint pjp - used refer book marks of AOP*/){
//Used to get the parameters of the method !
Object[] arguments = joinPoint.getArgs();
for (Object object : arguments) {
System.out.println("List of parameters : " + object);
}
System.out.println("Method name : " + joinPoint.getSignature().getName());
log.info("beforeAdvicing...........****************...........");
log.info("Method name : " + joinPoint.getSignature().getName());
System.out.println("************************");
}
但是有些东西我在其他资源看到的是,
@Around("execution(* com.mumz.test.spring.aop.BookShelf.addBook(..))")
public void aroundAddAdvice(ProceedingJoinPoint pjp){
Object[] arguments = pjp.getArgs();
for (Object object : arguments) {
System.out.println("Book being added is : " + object);
}
try {
pjp.proceed();
} catch (Throwable e) {
e.printStackTrace();
}
}
这里什么ProceedingJoinPoint
会做特别的比较“JointPoint`?
还什么pjp.proceed()
能为我们做什么?
Thans您的回复。所以你说的'pjp.proceed()'将调用两次'addBook()'方法? –
不,首先会调用aroundAdvice方法,然后调用addBook()。 –
你可以通过调试来看到它。 –