Can someone post a working example of how to use @args in an aspect? I have an annotation that I am trying to use to "mark" certain string arguments as a "customer_id" so that I can perform a security check on them:
Code:@Retention(RetentionPolicy.RUNTIME) public @interface CustomerAnnotation { public String name(); public String value(); }Code:@Aspect public class CustomerAspect { @Before("execution(* *(@com.example.test.annotation.CustomerAnnotation(*)))") private void testPointCut() { // the pointcut signature System.out.println("it works!"); } }I have tried what seems like a trillion ways to get "it works!" to print out but nothing works :-(Code:public class TestCommand { public void execute(@CustomerAnnotation(name = "foo", value = "foo") String customer_id) { System.out.println("executed"); } }
I have also tried this approach to no avail :-/:
Code:@Aspect public class CustomerAspect { @Before("@args(com.example.test.annotation.CustomerAnnotation)") private void testPointCut() { // the pointcut signature System.out.println("it works!"); } }


Reply With Quote
