Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

AspNew.aj 685B

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