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.

AnnotationBinding.aj 687B

12345678910111213141516171819202122232425262728293031323334353637
  1. import org.aspectj.lang.reflect.MethodSignature;
  2. import org.aspectj.lang.annotation.SuppressAjWarnings;
  3. import java.lang.annotation.*;
  4. public aspect AnnotationBinding {
  5. pointcut callToABeanMethod(Bean beanAnnotation) :
  6. call(@Bean * *(..)) && @annotation(beanAnnotation);
  7. @SuppressAjWarnings
  8. Object around(Bean beanAnnotation) : callToABeanMethod(beanAnnotation) {
  9. return proceed(beanAnnotation);
  10. }
  11. public static void main(String[] args) {
  12. D d = new D();
  13. d.bar();
  14. }
  15. }
  16. @Retention(RetentionPolicy.RUNTIME)
  17. @interface Bean {
  18. boolean issingleton() default true;
  19. }
  20. class C {
  21. @Bean
  22. public void foo() {}
  23. }
  24. class D extends C {
  25. public void bar() { foo(); }
  26. }