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.

CaseF.java 750B

1234567891011121314151617181920212223242526272829303132
  1. // TESTING: Factory method directly takes the type specified in the Mixin target (strongly typed)
  2. import org.aspectj.lang.annotation.*;
  3. public class CaseF {
  4. public static void main(String[]argv) {
  5. CaseF cc = new CaseF();
  6. ((I)cc).methodOne(); // will only succeed if mixin applied
  7. }
  8. public String toString() {
  9. return "CaseF instance";
  10. }
  11. }
  12. aspect X {
  13. @DeclareMixin("CaseF")
  14. public static I createImplementation(CaseF cf) {
  15. System.out.println("Delegate factory invoked for "+cf.toString());
  16. return new Implementation(cf);
  17. }
  18. }
  19. interface I {
  20. void methodOne();
  21. }
  22. class Implementation implements I {
  23. public Implementation(CaseF cf) {}
  24. public void methodOne() {
  25. System.out.println("methodOne running");
  26. }
  27. }