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.

CaseD.java 707B

12345678910111213141516171819202122232425262728293031
  1. // TESTING: factory method is non static and takes the object for which the delegate is being created
  2. import org.aspectj.lang.annotation.*;
  3. public class CaseD {
  4. public static void main(String[]argv) {
  5. CaseD cd = new CaseD();
  6. ((I)cd).methodOne(); // will only succeed if mixin applied
  7. }
  8. public String toString() {
  9. return "CaseD instance";
  10. }
  11. }
  12. aspect X {
  13. @DeclareMixin("CaseD")
  14. public I createImplementation(Object o) {
  15. System.out.println("Delegate factory invoked for "+o.toString());
  16. return new Implementation();
  17. }
  18. }
  19. interface I {
  20. void methodOne();
  21. }
  22. class Implementation implements I {
  23. public void methodOne() {
  24. System.out.println("methodOne running");
  25. }
  26. }