I am using Spring AOP (with AspectJ annotation style support) and want to execute code if a method is annotated with a specific annotation (WsTransaction).
Here is my aspect:
This is an example class where I expect it to run:Code:@Aspect @Component public class ExampleAspect { @Pointcut("execution(* example.*.ws.*.*(..))") public void isWebService() {} @Pointcut("@annotation(example.common.ws.WsTransaction)") public void isAnnotated() {} @Before("isWebService() && isAnnotated()") public void before() { System.out.println("before called"); } }
When I change @Before to only use isWebService() it is called but when I try it with isWebService() && isAnnotated() or just isAnnotated() nothing seems to happen.Code:package example.common.ws; @Endpoint public class SomeEndpoint { @WsTransaction() // I want advice to execute if this annotation present @PayloadRoot(localPart = "SomeRequest", namespace = "http://example/common/ws/") public SomeResponse methodToBeCalled(SomeRequest request) { // Do stuff return someResponse; } }
I have <aop:aspectj-autoproxy/> in my Spring config.
The endpoint is created by Spring (using component-scan).
The annotation's retention policy is runtime.
Spring version is 3.0.3.RELEASE
I am not sure what is wrong or what I can try to debug. Any help will be appreciated.


Reply With Quote