I am looking to create around advice on methods with a specific return type. I'm curious if something like that is possible. I have this method for example:
@Around("execution(* com.mytest.example.*Resource.*(..))")
public Object restCallMade(ProceedingJoinPoint pjp) {
Response response = null;
try {
response = (Response) pjp.proceed();
// Do other stuff
} catch (Throwable e) {
}
return response;
}
However, if possible I would like that this advice only gets called if the return type of the method is Response. Is that possible?
Just use the (fully qualified) type name instead of the joker * in the pointcut's method signature:
@Around("execution(org.foo.Response com.mytest.example.*Resource.*(..))")
public Response restCallMade(ProceedingJoinPoint pjp) {
Response response = null;
try {
response = (Response) pjp.proceed();
// Do other stuff
} catch (Throwable t) {}
return response;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With