Skip to main content

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

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.

 

 

 


Back to the top