Skip to main content

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

right - for 

> to log the entry and exit of methods in the 
> business code, but not in any getters or setters

do 

  execution(* *(..))          // any method-execution
  && ! execution(* get*(..))  // except for getters
  && within(com.business..*)  // in the lexical scope of business
  && {any cflow/other constraints...}

otherwise, you get *all* kinds of join points (field set/get,
constructor-execution, etc.)

Wes

> ------------Original Message------------
> From: Jonathan Amir <jamir@xxxxxxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Tue, Sep-7-2004 4:29 PM
> Subject: 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:
> 
> http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/progguide/language-joinPoints.html#d0e1288
> 
> 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.
> 
> Thanks,
> 
> Jonathan
> 
> 
> 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.
> > 
> > Thanks!
> > 
> > cheers,
> > -adrian.
> > --
> > Adrian Powell
> > Centre for IBM e-Business Innovation :: Vancouver
> > apowell@xxxxxxxxxx / 604-297-3194
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 




Back to the top