Java 从AOP中的方法B返回后,如何访问方法A中的方法属性?
我的Spring后端项目中有一个方法A,在执行不同的方法B之后应该调用它。返回方法B的类型是无效的,但在成功执行方法B之后,我需要将一个输入参数从方法B传递给方法A 方法B:Java 从AOP中的方法B返回后,如何访问方法A中的方法属性?,java,spring,aop,spring-aop,Java,Spring,Aop,Spring Aop,我的Spring后端项目中有一个方法A,在执行不同的方法B之后应该调用它。返回方法B的类型是无效的,但在成功执行方法B之后,我需要将一个输入参数从方法B传递给方法A 方法B: void invite(int eventId, int userId, Integer[] invitees, EventInvitationMethod push, String content); 方法A: @AfterReturning(pointcut="execution(* xyz.zzz.
void invite(int eventId, int userId, Integer[] invitees,
EventInvitationMethod push, String content);
方法A:
@AfterReturning(pointcut="execution(* xyz.zzz.api.event.service.EventService.invite(..))")
public void newInvitation(InputParameter of B - int userId){
///Do something with userId
}
有可能吗?我需要确定的是,方法B已成功执行以处理方法A
任何帮助都会很好。好的,我解决了如下问题:
@AfterReturning(pointcut = "execution(* xyz.zzz.api.event.service.EventService.invite(..))")
public void newInvitation(JoinPoint joinPoint) {
Object[] args = joinPoint.getArgs();
///I am working with args, looking for an instance of Integer[]
}
希望它能对其他人有所帮助。为什么不调用invite()方法的最后一行newInvitation(userId)?因为invite调用repository,repository作为本机查询调用数据库中的存储过程,所以我没有实现此方法。