Skip to main content

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

Ok, I changed the pointcut to call, but with a small HelloWorld app:

public class HelloWorld {
	
	public HelloWorld() {
		System.out.println("In HelloWorld constructor");
	}
		
	
	public static void main(String[] args) {
		HelloWorld world = new HelloWorld();
	}
}

I still get following output:
Entering [com.aspects.test.HelloWorld.<init>]
This: null
Target: null
Entering [java.io.PrintStream.println]
This: com.aspects.test.HelloWorld@9664a1
Target: java.io.PrintStream@1a8c4e7
In HelloWorld constructor


Why the This and the Target are null when calling the HelloWorld
constructor?




-----Original Message-----
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Alexandru Popescu
Sent: 20. helmikuuta 2005 17:38
To: aspectj-users@xxxxxxxxxxx
Subject: 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-----
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top