当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Pointcut for getting all beans in @Configuration class

问题描述:

I use Spring Integration and have a flow described in some @Configuration annotated class (@Bean and @Autowired marked methods), f.e. CustomFlow.class.

If any element in flow throw exception I would like to intercept it with @AfterThrowing advice and do some actions (notification, write smth to DB, etc).

So the question is - how to write proper pointcut to get all beans in this case?

网友答案:
@Aspect
public class LoggingAspect {

@AfterThrowing(
 pointcut = "execution(*(..))",
 throwing= "error")
 public void logAfterThrowing(JoinPoint joinPoint, Throwable error) {
  //...
 }
}    

and then the configuration:

<aop:after-throwing method="logAfterThrowing" throwing="error"   />
分享给朋友:
您可能感兴趣的文章:
随机阅读: