diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/InnerClassNaming.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/InnerClassNaming.java')
-rw-r--r-- | tests/new/InnerClassNaming.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/new/InnerClassNaming.java b/tests/new/InnerClassNaming.java new file mode 100644 index 000000000..bf0ec54e7 --- /dev/null +++ b/tests/new/InnerClassNaming.java @@ -0,0 +1,50 @@ +import java.awt.*; +import java.awt.event.*; +import org.aspectj.testing.Tester; + +/* + * I would like to listen to events fired by a whiteboard swing widget. + * When I listen to method invocations from the widget itself in + * an aspect, + * there + * is no problem (like say getPreferredSize()). + * + * But, when I want to listen to events fired by a mouse adapter + * from which + * I derived + * an inner class in the whiteboard like this : + * + * SOLUTION: Replace all super.inner to super$inner. + */ + +public class InnerClassNaming { + public static void main(String[] args) { + new InnerClassNaming(); + } + + InnerClassNaming() { + MouseListener listener = new MyListener(); + addMouseListener(listener); + } + + void addMouseListener(MouseListener listener) {} + + class MyListener extends MouseAdapter { + public void mousePressed(MouseEvent e) { + System.out.println("mousPressed: " + e); + } + } +} + +aspect MyAspect /*of eachobject(instanceof(InnerClassNaming.MyListener))*/ { + + pointcut pressed(InnerClassNaming.MyListener ls): + //instanceof(ls) && executions(* mousePressed(..)); + this(InnerClassNaming.MyListener) && + target(ls) && + execution(* mousePressed(..)); + + before(InnerClassNaming.MyListener ls): pressed(ls) { + System.out.println(thisJoinPoint); + } +} |