aop in ruby

F

Florian Weber

hello!

im currently working on a aop library for ruby. most of the things like
pointcuts and
joinpoints work fairly well. unfortunately i can not find a elegant
solution for something:

- it must be possible to pass objects which have aspects weaved around
without
running into a deadlock, this is especially important for passing them
to advices.

- advices must be also working when methods of the object are called by
the
object itself.

basically i see two possibilities:

1) via a proxy, which holds the original object, creates each method
existing on
the original object for the proxy. something like:

def foo
SomeAspect.before...
@object.foo
end
(totally oversimplified, i know =)


2) via rewriting the methods on the object itself. weaving in the
advices
directly and just calling the original method via the id..

the problem is that neither of those possibilities solve both problems.
the first one makes it impossible that advices are applied when methods
are called from within the object itself, since the method is not
called via
the proxy.. (is it possible to do something nasty like redefining
'self' for
a object? =)

the second one can lead to quite serious trouble, because there is no
way
to guarantee that the method is called without any advices (for example
by
advices themself)

is there any other possibility to solve this in ruby? amy i overseeing
something?

thanks a lot for any tipp!

ciao!
florian
 
G

gabriele renzi

il Thu, 22 Jul 2004 06:34:54 +0900, Florian Weber
is there any other possibility to solve this in ruby? amy i overseeing
something?

mh.. two things.
First: did you already looked at AspectR, the prior[] hack from (IIRC)
Robert Feldt, and the defadvice from mauricio fernandez [3]

Second:
what your #2 problem mean?
I'm not an AOP expert at all, but why you'd need to call the base
method without any aspects? I thought that every pre and post thingy
should be forced to work with the other, am I wrong?

[1] aspectr.sourceforge.ne
[2] sorry don't have a link handy :/
[3] http://www.thekode.net/ruby/techniques/CapturingMethods.html
 
F

Florian Weber

is there any other possibility to solve this in ruby? amy i overseeing
something?

mh.. two things.
First: did you already looked at AspectR, the prior[] hack from (IIRC)
Robert Feldt, and the defadvice from mauricio fernandez [3]

yes. i checked out aspectr. its quite great. there are a couple of
things
which i dont like about it. but it definatelly helps a lot.

however it has the same issues. its not possible to pass the a
advice-free object to the advices.
Second:
what your #2 problem mean?
I'm not an AOP expert at all, but why you'd need to call the base
method without any aspects? I thought that every pre and post thingy
should be forced to work with the other, am I wrong?

because it will cause a endless loop..

if the current method is named 'foo', within this method i apply a
advice,
to which i pass the current object itself.. and within the advice i
again
call the foo method of the object... bang! loop..

however i wonder if this is just a normal thing and should be taken
care of by the user itself..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

AOP bigger picture 3
The likes of AOP (1 of 2) 1
AOP in Ruby ... 8
AOP and debugging 0
AOP and Ruby 4
[ANN] [RCR] Cut-based AOP 77
rolling your own AOP 0
easy AOP right now using evil.rb 2

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top