2015-11-03 51 views
0

我在我的Spring后端项目中有方法A,应该在执行不同的方法后调用 - B.方法B的返回类型是void,但是我需要将方法B中的一个输入参数传递给方法A,成功执行方法B.如何从AOP中的方法B返回后访问方法A中的方法属性?

方法B:

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.

任何帮助都会很棒。

+0

为什么不调用newInvitation(userId)方法invite()的最后一行? –

+0

由于邀请调用的存储库调用DB中的存储过程作为本机查询,所以我没有实现此方法。 –

回答

0

OK,我喜欢解决了这个问题:

@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[] 
} 

希望它会帮助别人。

相关问题