[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
AW: [aspectj-users] Using AJ to change program flow
|
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:
Wes Isberg wrote:
> Sorry, this would be great, but AspectJ doesn't work that way.
>
> The short story is that the parameter evaluation happens before the call
join point,
>before any advice could short-circuit. There's a longer discussion if you
search
>the mail archive for "parameter evaluation", e.g.,
>
>http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg01390.html
>http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg01408.html
>
>Personally, I combine log API's with standard rendering; there aren't too
>many variants:
>
> log(String label)
> log(String label, Object item)
> log(String label, Object[] items)
>
>Then my advice or a pluggable renderer can decide how/when to evaluate
>the arguments. But this doesn't help for existing code.
>
>Wes
-----Ursprüngliche Nachricht-----
Von: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] Im Auftrag von Jim Carroll
Gesendet: Montag, 16. August 2004 14:02
An: aspectj-users@xxxxxxxxxxx
Betreff: [aspectj-users] Using AJ to change program flow
I have been playing with AJ; doing some simple things like adding tracing to
my code base but I wanted to write something that would change the program
flow based on some criteria and I'm not sure if it's supported. As an
example I have a lot of code with log statements like:
log.log("some" + " complex" + " string" + " statement);
and I wanted to use AJ to effectively insert a conditional in front of each
statement like:
if (logIsOn) log.log("some" + " complex" + " string" + " statement);
which would conditionally change the program flow. I can't seem to figure
out how to do this (or if it is possible).
Any suggestions?
Thanks
Jim Carroll
__________________________________________________________________
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