[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] pointcut definition problems

I think that if you have a class in com.business..* and somewhere in that class you call StringBuffer.append(), that method call would be captured in your pointcut. The same thing applies to getter and setters.

The issue is with understanding how within and withincode works when used in conjunction with call and execution. I suggest reading this page:


If the link is not working, go to the aspectj documentations (http://www.eclipse.org/aspectj/) and click on the title "call vs. execution" in chapter 2.

Secondly, I think that you need to explicitly add either a call or execution to your pointcut, otherwise you risk catching too many join points.



Adrian Powell wrote:

Hi all,

I'm working on refining a trace aspect and am having troubles pruning the output. I would like to log the entry and exit of methods in the business code, but not in any getters or setters. This is my pointcut:

pointcut perfExecExec(ControllerCommandImpl controller):
cflowbelow(execution(* ControllerCommandImpl+.performExecute()))
&& this(controller)
&& !within(TraceAspect)
&& within(com.business..*)
&& !withincode(* *.get*(..));

(the cflowbelow() is added so we can log the session information with each statement.)

The problem is that when I log thisJoinPointStaticPart.getSignature().getDeclaringTypeName() and getSignature().getName(), I am getting:

- java.lang.StringBuffer.append() (and other library methods) which I thought was blocked by the "within(com.business..*)" and
- any number of get() methods, both inside and outside of the com.business.* hierarchy

I've tried a number of variations of this pointcut, but none seem to work. Considering that I'm not weaving either the Java runtime jars or any of our library jars, the appearance of entry and exit statements for library methods is really confusing me. It makes me think there's something simple but profound that I am missing. Can anyone spot it, because I'm lost.


Adrian Powell
Centre for IBM e-Business Innovation :: Vancouver
apowell@xxxxxxxxxx / 604-297-3194