# Advising JRuby code from AspectJ?

**URL:** <https://www.ruby-forum.com/t/advising-jruby-code-from-aspectj/106679>\
**Category:** Ruby\
**Created:** [June 13, 2007, 7:21am UTC](https://www.ruby-forum.com/t/advising-jruby-code-from-aspectj/106679 "2007-06-13T07:21:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Susan\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f05b48/32.png) [@Susan\_D](https://www.ruby-forum.com/u/Susan_D)\
**Post date:** [June 13, 2007, 7:21am UTC](https://www.ruby-forum.com/t/advising-jruby-code-from-aspectj/106679/1 "2007-06-13T07:21:19Z")

</div>

We’re developing a RESTful web application, and we’re looking at running  
Rails under JRuby for many of our services. The front end is likely to  
be Java, as we’re kitbashing an existing OSS project into something that  
fits our needs a bit better.

One of our big requirements is a billing subsystem that supports a wide  
number of pricing models, and the ability for our sales/marketing people  
to introduce new ones on the fly. Another is a robust auditing  
subsystem. Both problems absolutely scream to be pulled out into  
aspects, which is fine for the bits of the system written in Java, but  
what about the Ruby code? I hear tell (handwave) that there are Ruby  
constructs that resemble aspects (handwave, handwave), but I’m new  
enough to Ruby to not have learned those patterns yet, and really, we’d  
like to only have to write our billing/auditing instrumentation code  
once.

Is there a good way to get AspectJ or Spring AOP aspects to advise JRuby  
classes? Alternatively, has anyone tried to use Spring AOP to use a  
JRuby class to advise Java code? Or is there some third possibility  
that I’m overlooking?

For that matter, where on Usenet is the good place to ask about AOP in  
general? I don’t see a specific group; is c.l.j.p the right place, or  
does one simply not exist yet?

Thanks in advance,  
– Sue –

–  
Susan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Sue needs developers! See [Sue needs developers! - A Puss Livens Drama — LiveJournal](http://futabachan.livejournal.com/145014.html)

---

<div class="post-metadata">

**Author:** ![Susan\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f05b48/32.png) [@Susan\_D](https://www.ruby-forum.com/u/Susan_D)\
**Post date:** [June 13, 2007, 7:54pm UTC](https://www.ruby-forum.com/t/advising-jruby-code-from-aspectj/106679/2 "2007-06-13T19:54:59Z")

</div>

“Advising” methods with behavior before, after, or around the method  
invocation itself is easy to do in Ruby. If your advice just needs to  
invoke  
other ruby code, then using these techniques would be better (probably)  
than  
trying to combine a Java-based AOP mechanism with JRuby classes, etc.  
There  
are also several basic AOP frameworks for Ruby, although they tend to be  
somewhat old or poorly documented.

However, if you need your ruby classes to invoke java services, then it  
might make sense to try Spring AOP.

I’ve been doing some work on AOP in Ruby and I’m interested in issues  
like  
this. Feel free to follow up with me privately if you would to discuss  
it  
further!

dean
