You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AspNew.aj 724B

12345678910111213141516171819202122232425262728
  1. import java.lang.annotation.Retention;
  2. import java.lang.annotation.RetentionPolicy;
  3. @Retention(RetentionPolicy.RUNTIME)
  4. @interface Secured {
  5. String value();
  6. }
  7. interface DemoService {
  8. @Secured("READ")
  9. void secureMethod();
  10. }
  11. class DemoServiceImpl implements DemoService {
  12. public void secureMethod() { }
  13. }
  14. aspect X {
  15. // None of these match, the subject at execution(secureMethod()) does not have the annotation
  16. // see https://github.com/eclipse-aspectj/aspectj/blob/master/docs/adk15notebook/joinpointsignatures.adoc#join-point-modifiers
  17. before(): execution(@Secured! * *Service+.*(..)) { }
  18. }
  19. public class AspNew {
  20. public static void main(String[] args) {
  21. new DemoServiceImpl().secureMethod();
  22. }
  23. }