2015-11-03 49 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[] 
} 

希望它會幫助別人。

相關問題