Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RubyForge-18089] Need a mechanism to suspend advice execution, especially during advice itself #20

Open
hedgehog opened this issue Jan 29, 2010 · 0 comments

Comments

@hedgehog
Copy link

Date:2008-02-15 18:22
Priority:3
Submitted By:Dean Wampler (deanwampler)
Assigned To:Dean Wampler (deanwampler)
Category:None
State:Open
Summary:Need a mechanism to suspend advice execution, especially during advice itself

Detailed description

A common problem in aspects is infinite recursion when the advice for a method calls the method, which invokes the advice for the method, ad infinitum. AspectJ handles this with several pointcut designators, e.g., !within(MyAspect) or !cflowbelow(adviceexecution()), etc.
While I want to add these sorts of designators eventually, it might be nice to add something more "rubyish" such as the following:

aspect :before, :calls_to => doit, :on_type => Foo  do |jp, object, *args|
  jp.while_suspending_advice do
     value = object.foo(args)
     ...
  end
end

JoinPoint#while_suspending_advice might take an optional list of JoinPoints, where if blank, all advices for all JoinPoints are bypassed, but if JPs are specified, only those are suspended within the block.

Note that this facility is only required for the general case where advice wants to call arbitrary methods that may have advice. If the advice just wants to call the same method that it is advising, there is already a workaround;
call jp.invoke_original_join_point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant