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.

pr108245.aj 658B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import java.io.Serializable;
  2. import java.lang.annotation.*;
  3. import java.lang.*;
  4. class Bean implements Serializable{
  5. private String name;
  6. public String getName() {
  7. return name;
  8. }
  9. @propertyChanger()
  10. public void setName( String name ) {
  11. this.name = name;
  12. }
  13. }
  14. @Retention( RetentionPolicy.RUNTIME )
  15. @Target({ ElementType.METHOD })
  16. @interface propertyChanger {
  17. }
  18. aspect pr108245 {
  19. public static void main(String[] args) {
  20. Bean b = new Bean();
  21. b.setName("hasBean");
  22. }
  23. pointcut callSetter( Bean b )
  24. : call( @propertyChanger * *(..) ) && target( b );
  25. before(Bean b) : callSetter(b) {
  26. System.out.println("before " + b);
  27. }
  28. }