Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: AW: [aspectj-users] Using AJ to change program flow

Jim,

It's better to think about join points as points in a running program, rather than thinking about text manipulation. In executing the source code for log(helperMethod()) the system will encounter at least 3 join points:
call helperMethod
  execute helperMethod
call log

Note that the call to helperMethod returns before the call to log starts. It has to run in this order (e.g., if helperMethod throws an exeception then the call will never happen).


Ron Bodkin
Chief Technology Officer
New Aspects of Software
o: (415) 824-4690
m: (415) 509-2895


> ------------Original Message------------
> From: jimfcarroll@xxxxxxxxxxxx (Jim Carroll)
> To: aspectj-users@xxxxxxxxxxx
> Date: Mon, Aug-16-2004 8:07 AM
> Subject: RE: AW: [aspectj-users] Using AJ to change program flow
>
> Vincenz,
> 
> Thanks for the response. I'm surprised about this. It seems that it 
> should work either way depending on how you pick out of the join points. 
> If the join points are 'calls' then the the parameter evaluation should 
> not execute. If the join point is 'execution' then I would expect it 
> to. I think this because I visualize what is taking place as the 
> insertion of code into the original source. I see the code inserted where a 
> 'call' is made when the 'call' join points are selected, but I see it as 
> inserting code into the method where 'execution' is used. So I would 
> have thought that an 'around' advice would put code 'around' the call (if 
> a 'call' joinpint is used) as follows:
> 
> aspect Logcheck
> {
>    pointcut logcall(): call[or execute](public Logger.log(..));
> 
>    around (): logcall() {
>       if (logIsOn)
>       {
>          proceed();
>       }
>    }
> }
> 
> ... would cause (in the case of the call) ....
> 
>     ...
>       log.log("bla" + " bla" + "bla" );
>     ...
> 
> to be 'converted' to:
> 
> 
>       if (logIsOn)
>       {
>          log.log("bla" + " bla" + "bla" );
>       }
> 
> But in the case the joinpoint was picked out using an 'execution' it 
> would modify the log call itself, e.g:
> 
>      public class Logger {
>       ...
>       public void log(String s)
>       {
>         if (logIsOn)
>         {
>            [... body of the original log method ...]
>         }
>       }
>       ...
>      }
> 
> 
> So, what is it about my understanding that is incorrect? (I can't seem 
> to access the thread you referenced so if the answer is simple and you 
> can straighten out my misunderstanding, please do).
> 
> Thanks
> Jim
>  
> 
> "Vincenz Braun" <vb@xxxxxxxxx> wrote:
> 
> >Hi,
> >
> >you can't do this at the moment.
> >You can have an around advice that prevents the actual call
> >of a log statement (described in the previous post with a conditional
> >proceed()). But the cost of the parameter creation
> >can not be avoided. Here is the post from Wes:
> > ...
> 
> __________________________________________________________________
> Switch to Netscape Internet Service.
> As low as $9.95 a month -- Sign up today at 
> http://isp.netscape.com/register
> 
> Netscape. Just the Net You Need.
> 
> New! Netscape Toolbar for Internet Explorer
> Search from anywhere on the Web and block those annoying pop-ups.
> Download now at http://channels.netscape.com/ns/search/install.jsp
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 



Back to the top