Spring AOP:如何将调用方法参数值转换为Spring Aspect类的通知方法

时间:2017-06-16 10:44:38

标签: spring spring-integration aop aspectj spring-aop

当我问这个问题时,我找不到任何解决方案。

要求:

目前我正在开发一个使用Spring Boot with Rest和Spring Integration的项目。

我的要求是将所有网关服务调用记录到审计表中,以确定两种方案的成功和失败。每个网关都包含必须存储在审计表中的网关特定信息。我使用spring AOP - @After Advice annotation来记录审计信息,但是这个注释方法期望审计值是网关服务CALLER方法的一部分。

示例:

@Autowired
com.study.pattern.sample.app.gateway.EmployeGatewayservice employeGatewayservice;

public EmployeOutput getEmployeInformation(EmployeInput employeInput,AuditInput auditInput)
{
    employeGatewayservice.getEmployeInfomation(employeInput);
}

如何在我的建议中获取auditInput对象。

@Pointcut("execution(* com.study.pattern.sample.app.gateway..*(..))")
     protected void gateWayCalls()
     {

     }

      @After("gateWayCalls()")
      public void logAfter(JoinPoint joinPoint) {
         **// Here i need auditInput Object**
     }

我在getEmployeInformation()上调用advice方法有局限性 因为某些服务方法包含非网关调用逻辑。

对于我的情况,我必须使用网关上的Aspect而不是服务方法。

我正在寻找一个解决方案,如何在我的春天获得Caller方法参数@After建议?

1 个答案:

答案 0 :(得分:0)

考虑使用import { Player } from '@vimeo/player';

MethodInterceptor
相关问题