Skip to main content

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


Thanks Wes and Jonathan, your tips are definately working to restrict the number of messages being logged.

I was still having a lot of unusual, unexpected and unpleasant results, though.  It seemed that I'd either get the initial entry point logged, everything (including system libraries), or nothing.  After some more work, I finally found my blunder.  I had:

pointcut fullFlow(ControllerCommandImpl controller) :
        cflow(execution (* ControllerCommandImpl+.performExecute()))
        && this(controller)
        && execution(public * *.*(..))
        ...

I was basing this off of the wormhole pattern of AspectJ In Action.  I only just now realized that it should be:

pointcut fullFlow(ControllerCommandImpl controller) :
        cflow(execution (* ControllerCommandImpl+.performExecute()) && this(controller))
        && execution(public * *.*(..))
        ...

(the "this(controller)" pointcut had to be moved inside the cflow().)  This makes sense to me now that I see it, but honestly, the cflow() and cflowbelow() had really foozled me  :)


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



"Wes Isberg" <wes@xxxxxxxxxxxxxx>
Sent by: aspectj-users-admin@xxxxxxxxxxx

09/07/2004 04:51 PM

Please respond to
aspectj-users

To
aspectj-users@xxxxxxxxxxx
cc
Subject
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
>


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top