[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[aspectj-users] Monitoring all method calls exception
|
- From: "Rob Austin" <austirob@xxxxxxxxxxxxxx>
- Date: Tue, 6 Nov 2007 19:22:54 +0000
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=ri060RZXfgjmtcc79iAZYVodsnUyqZRsm0ks520Z3nE=; b=bK83iZZUKtIcX1yn/C+7ryXkVmI7w8akFWojkrUQNlUS2r5jIe5/Qo/CbuN/ueZRf94x3trCrtGWdyNgI99Yre1XqOxqpJ8ER8d9hlKG3v6yOe+RO+9PyrerRP7s3C3tFV/PcqXlr152w37Iu6nDdN9Mu08oqNPN38dp53AyFtY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=KWZE9uVcpHrEbAe5yZfkfaeVcq1jxzdz2M6aIfLF8C8UMI4hoUzkA/IY4s/uOzTn/rSYeEqF85WvdB+5bLgA86MprArCaM8l7wNXyscMaEDPx93APG8pSKoj1sxcgjFKnLPtunPLyLRgzmEgz92itarUbO4h2zTphtNNIN92Zs0=
Hi,
I want to write an aspect that logs any call to my Package (myPackage) from outside of it - those I don't expect in other words.
I'm facing the following problems with my newbie code:
1. I thought I could restrict my advice to calls made outside of my package by using within(! myPackage.bookTrading.*
) , but as you can see in the output below, it still seems to include calls made from within my package.
2. Where a call is to a method contained in a jar rather than in code for which the source is included in the project, thisJoinPoint
.getTarget().getClass errors out with a nasty message, something along the lines of "Attempt to send a message to a non object value". I assume that this behaviour would be expected, but any ideas how I can trap for this rather than letting an error be raised.
Really appreciate any help,
Thanks
Rob
public
aspect WatchMethodCalls {
pointcut WatchAll(): call(* myPackage
..*.*(..))
&& within(! myPackage.bookTrading.*) &&
within(! WatchMethodCalls);
before( ) : WatchAll( )
{
System.out.println("thisJoinPoint.getTarget().getSignature() " +thisJoinPointStaticPart
.getSignature());
System.out.println("thisJoinPoint.getTarget().getSourceLocation() " + thisJoinPointStaticPart
.getSourceLocation());
System.out.println("thisJoinPoint.getTarget().getClass() " + thisJoinPoint
.getTarget().getClass());
}
Sample output;
thisJoinPoint.getTarget().getSignature() Vector myPackage.bookTrading.BookBuyerAgentMalicious.access$0(BookBuyerAgentMalicious)
thisJoinPoint.getTarget().getSourceLocation()
BookBuyerAgentMalicious.java:288
Error occurred in WatchAll:java.lang.NullPointerException
at apoptotic.BlockMethodCalls.ajc$before$apoptotic_BlockMethodCalls$1$2e232b3e
(BlockMethodCalls.aj:22)
at apoptotic.bookTrading.BookBuyerAgentMalicious$BookNegotiator.action(BookBuyerAgentMalicious.java:288)
at jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:340)