I've checked other SO questions like this but none seem to apply.
I have my Service class:
package com.test.demo.service;
import com.test.demo.controller.Controller2;
import com.test.demo.model.SettlementTransaction;
import org.springframework.stereotype.Service;
@Service
public class TestService {
public Controller2.AcctDetails testAcctDeets(Transaction transaction){
and my aspect:
@AfterReturning(pointcut = "execution(* com.test.demo.service.TestService.testAcctDeets(..))", returning = "response")
public void interceptRequest(Controller2.AcctDetails response, JoinPoint thisJoinPoint) {
System.out.println(thisJoinPoint);
for (Object arg : thisJoinPoint.getArgs()) {
if (arg instanceof String)
System.out.println(" request = " + arg);
}
System.out.println(" response = " + response.toString());
}
but I keep getting the error:
Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
Any help is appreciated. Thank you!
From the reference documentation : Access to the Current
Any advice method may declare, as its first parameter, a parameter of type
org.aspectj.lang.JoinPoint
(note that around advice is required to declare a first parameter of typeProceedingJoinPoint
, which is a subclass ofJoinPoint
This is documented as continuation to the topic Advice Parameters which has reference to this : Spring offers fully typed advice, meaning that you declare the parameters you need in the advice signature (as we saw earlier for the returning and throwing examples).
When read together , when passing advice parameters and the advice method also has JointPoint
or any of its subclas as another parameter , the latter should be declared as the first parameter.
So in this case , the valid method signature would be
@AfterReturning(pointcut = "execution(* com.test.demo.service.TestService.testAcctDeets(..))", returning = "response")
public void interceptRequest(JoinPoint thisJoinPoint, Controller2.AcctDetails response) {
// ..
}