0

I have method A in my Spring backend project that should be invoked after execution of different method - B. Returning type of method B is void, but I need to pass one input parameter from method B to method A, after successful execution of method B.

Method B:

void invite(int eventId, int userId, Integer[] invitees,
        EventInvitationMethod push, String content);

Method A:

@AfterReturning(pointcut="execution(* xyz.zzz.api.event.service.EventService.invite(..))")
public void newInvitation(InputParameter of B - int userId){
     ///Do something with userId
}

Is it possible to do that? I need to be sure, that method B was executed successfully to process method A.

Any help will be great.

m.aibin
  • 3,528
  • 4
  • 28
  • 47

1 Answers1

0

OK, I solved problem like this:

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

Hope it will help somebody.

m.aibin
  • 3,528
  • 4
  • 28
  • 47