Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] generate a StackTraceElement

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

[quote Valerio Schiavoni::on 2/10/2005 5:17 PM]
| Hello
|
| i'd like to to generate a stack trace element everytime an advice is executed.
|
| what i have now is:
|
|     before(Object obj): myConstructor(obj) {
|           traceEntry("" + thisJoinPointStaticPart.getSignature(), obj);
|
|           StackTraceElement ste = new StackTraceElement
| (thisJoinPoint.getSignature().getDeclaringType().getName(),
|                 thisJoinPoint.getSignature().getName(),
|                 thisJoinPoint.getSourceLocation().getFileName(),
|                 thisJoinPoint.getSourceLocation().getLine());
|
|   System.out.println(ste);
|
|     }
|
|     after(Object obj): myConstructor(obj) {
|              traceExit("" + thisJoinPointStaticPart.getSignature(), obj);
|
| StackTraceElement ste = new StackTraceElement
| (thisJoinPoint.getSignature().getDeclaringType().getName(),
|                     thisJoinPoint.getSignature().getName(),
|                     thisJoinPoint.getSourceLocation().getFileName(),
|                     thisJoinPoint.getSourceLocation().getLine());
|              System.out.println(ste);
|     }
|
| What i'd like to do is to create a StackTracerAspect, which contains the
| construction of  the StackTraceElement.
|
| My question so is: how do I define a pointcut which intercept the after and
| the before advices ? Is it this the right approach?
|

The only available pointcut related to aspects is the adviceexecution() but you cannot refine it
further to match a before advice and after advice.

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

iD8DBQFCC33TTTDTje0R2dgRAms5AJ0frBiZqdwEVnAJJfRhtVVjmE8YTgCfTqF2
p2b+i+prjUabd+mAkGdcSWA=
=uP7V
-----END PGP SIGNATURE-----


Back to the top