* 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)
*

**
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to