Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Tracing Aspect

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[quote Sami Lakka::on 2/20/2005 5:31 PM]
| Hi,
|
|
| I'm learning AspectJ and I would like to create a tracing aspect that shows
| method calls made to any object, as well as the calling object (this) and
| the called object (target). What kind of a pointcut should I make? My
| current tracing-aspect looks like following:
|
|
|
| pointcut traceMethods() : (execution(* *.*(..))
|
|
|           || execution(*.new(..))) && !within(TraceAspectV1);
|
|
|
| before() : traceMethods() {
|
|         Signature sig = thisJoinPointStaticPart.getSignature();
|
|
|
|         System.out.println("Entering ["
|
|                           + sig.getDeclaringType().getName() + "."
|
|                           + sig.getName() + "]");
|
|         System.out.println("This: "+thisJoinPoint.getThis());
|
|         System.out.println("Target: "+thisJoinPoint.getTarget());
|
|     }
|
|
|
|
|
| The thisJoinPoint.getTarget- doesn't seem to return the correct called
| object.
|
|
|
|
|
|
|
|
You stated you want to track *method calls*, so you should use *call* pointcut and not *execution* ;-).

- --
:alex |.::the_mindstorm::.|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCGK71TTDTje0R2dgRAk6JAJ4vbvzYKZShtcYlLQ8hGU/a1GQ13wCfXmxy
5mfyyGcKklUtNXWdRhN1Kko=
=Qe5J
-----END PGP SIGNATURE-----


Back to the top