Possible Duplicate:
@AspectJ pointcut for all methods of a class with specific annotation
I am trying to write a pointcut for all methods of a class which have a custom annotation. Here's the code
Annotation:
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(value = RetentionPolicy.RUNTIME) @Target(value = ElementType.METHOD) public @interface ValidateRequest {}
Method in Controller:
@RequestMapping(value = "getAbyB", produces = "application/json") @ResponseBody @ValidateRequest public Object getAbyB(@RequestBody GetAbyBRequest req) throws Exception { /// logic }
Aspect:
@Aspect @Component public class CustomAspectHandler { @Before("execution(public * *(..))") public void foo(JoinPoint joinPoint) throws Throwable { LOG.info("yippee!"); } }
applicationContext:
`<aop:aspectj-autoproxy />`
I've been trying various advices, mentioned below, but none seem to work (except for the one used above)
@Around("@within(com.pack.Anno1) || @annotation(com.pack.Anno1)")
@Around("execution(@com.pack.Anno1 * *(..))")