I have a custom method type annotation and its aspect, I am applying this annotation on Abstract class method. The annotation is not working in-spite of defining pointcuts with package level and even method level Is there any constraint on applying it to abstract method.? I have tried defining pointcuts with all ways commented above method translate in class TranslateAspect
package com.example.annotations;
import java.lang.annotation.*;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Translate {
}
Aspect Class
package com.example.annotations;
@Aspect
@Slf4j
public class TranslateAspect {
//@Around(value = "@annotation(com.example.annotations.Translate)")
//@Around("execution(* com.example.services.AbstractCouponFacade.getCouponsForCart(..)) ")
//@Around("translatePointcut()")
public Object translate(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
Signature methodSignature = proceedingJoinPoint.getSignature();
MethodSignature signature = (MethodSignature) methodSignature;
Object responseObject = proceedingJoinPoint.proceed();
// do smoething
return responseObject;
}
@Pointcut("execution(* com.example.services.*.*(..)) " +
"&& execution(public * *(..))) "+
"&& @annotation(com.example.annotations.Translate)" )
public void translatePointcut() {}
}
Abstract class on whose method annotation is applied
package com.example.services;
public abstract class CouponList extends BaseFacadeWrapper {
public CouponList(AbstractBaseFacade abstractBaseFacade) {
super(abstractBaseFacade);
}
public abstract CartDTO fetchOrCreateCart();
public abstract List<CustomerCouponResponseDTO> fetchCoupons(CartDTO cartDTO);
@SneakyThrows
@Translate
public BizCartCouponResponseDTO method(List<CustomerCouponResponseDTO> couponList, CartDTO cartDTO) {
//so something
return BizCartCouponResponseDTO.builder()
.appliedCoupon(appliedCoupon)
.applicableCoupons(applicableCoupons)
.nonApplicableCoupons(noneApplicableCoupons)
.build();
}
}