I want to create a pointcut at @FeignClient with Spring aop like
@Slf4j
@Aspect
@Component
@Order(3000)
public class FeignAspect {
@Pointcut("@within(org.springframework.cloud.openfeign.FeignClient)")
public void feign() {
}
@Before("feign()")
public void before(JoinPoint joinPoint) {
log.debug("==>> 【feign request】method invoked : {}.{}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());
log.debug("==>> 【feign request】request params : {}", JSON.toJSONString(joinPoint.getArgs(), true));
}
@AfterReturning(value = "feign()", returning = "response")
public void afterReturning(Response response) {
log.debug("<<=== 【feign response】 : {}", JSONObject.toJSONString(response, serializerFeatures));
if (ServerRespCode.isCodeNotService(response.getHead().getResponseCode())) {
log.error("<<=== 【feign error】 an error occur when invoke feign service: "
+ JSONObject.toJSONString(response, serializerFeatures));
throw new FeignException(response.getHead().getResponseDesc(), response.getHead().getResponseCode());
}
}
}
but it not work(both of before() and afterReturning()), is this because there is not a @Inherited annotation on @FeignClient? I guess Aop creates proxy a subclass of interface with pointcut,and the proxy subclass cannot inherite @FeignClient from parent interface.
It's usefull to do like so, can you add an @Inherited on @FeignClient?