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.

Asp.aj 800B

1234567891011121314151617181920212223242526272829303132333435
  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 http://www.eclipse.org/aspectj/doc/next/adk15notebook/join-point-modifiers.html
  17. before(): execution(@Secured * *Service+.*(..)) { }
  18. before(): execution(@Secured * *Service.*(..)) { }
  19. before(): execution(@Secured * DemoService.*(..)) { }
  20. }
  21. public class Asp {
  22. public static void main(String[] args) {
  23. new DemoServiceImpl().secureMethod();
  24. }
  25. }