Thursday, August 2, 2007

Spring Rails Plugin 0.1

Well, I finally checked in my code for a Spring Rails plugin. Consider it pre-alpha at this point. It's unit tested, and I made a simple example app to prove that it works. But that's about it. So if you find it useful, try it out and let me know so I can decide where to go with it next.

To install the plugin:

script/plugin install svn://rubyforge.org/var/svn/jruby-extras/trunk/rails-integration/plugins/spring


You'll need to get a basic Rails application working with the goldspike plugin in order for the Spring plugin to be of use. Currently it loads the Spring ApplicationContext by getting it from the ServletContext (which assumes you are using the Spring context listener to put it there). So if you're not running Rails in a servlet engine it doesn't work. If there is real interest in having the plugin be able to get an app context from somewhere else I'll look at supporting that down the road.

For an example of how to use it in a controller, see my previous post.

Why you shouldn't use it

If you're a Java programmer new to (J)Ruby and are thinking: "Awesome, I'll use Spring in all my Rails apps because Spring is awesome!" you need to hold up a second. Spring is awesome -- when you are developing Java applications. But in Ruby, dependency injection turns out to be unnecessary a whole lot of the time. This is because the Ruby language allows you to change things in a more straightforward way. And even if there were cases where you needed DI in Ruby there are probably better choices. I see the Spring plugin being useful where you have existing J2EE code wired together with Spring and want to front end it in JRuby on Rails. So use this plugin if you need it, but if you don't, then don't.

Don't take my word for DI and Ruby, my friend Jim had this blog post about it after our IM conversation. See the comments where other Ruby heavyweights weigh in on the subject.

9 comments:

Mike McKinney said...
This comment has been removed by the author.
Mike McKinney said...

amen (per: why not to use this plugin)

great work man!

Benjamin Stein said...

Thanks for getting this project started! I'm currently integrating a large Spring app with an existing Rails app so this was obviously of interest. Looks like we're still quite a ways away from production with this stuff, but certainly an interesting & fun project to be working on.
I couldn't quite get your Spring plugin working, but didn't have enough time to properly debug. Hopefully this week. I documented my experience here: http://benjaminste.in/2007/08/06/deploying-a-rails-app-in-a-warfile-on-tomcat-using-jdbc/

Unknown said...

Cool!
It is very good news for me since I'm now working on integrating rails UI with some java business logic beans.
I will check out your plugin today, and try it.
Keep up with good work!

Unknown said...
This comment has been removed by the author.
teramoney said...

buy eden gold
Runescape gold
buy Runescape gold

cheap wow gold
cheapest wow gold
lotro gold

Tera online
Tera gold

rsgoldfeng said...

Appreciate yourCheap RS Gold finding that project commenced! I am just presently adding a substantial Springtime iphone app with the pre-existing Bed rails iphone app so this ended up being naturally of interest. Appears like we're nonetheless a good
Buy Guild wars 2 Goldmethods clear of generation using this type of material, but a fascinating & enjoyable challenge being working on

rscredits said...

buy runescape gold with 5% discount code:CHRISTMAS.

Details: http://www.rsorder.com/profile/news/read/id/443

Free 200M runescape gold Giveaway on RSorder Flash Sale! Time: 03:00 AM on December 21, 2012 GMT

To know more: http://www.rsorder.com/profile/news/read/id/441

Like RSorder Facebook to Get 200M Free rs gold! If our facebook fans reach to 10,000, we will send out totally 200M free RS gold.

Rsorder facebook : http://www.facebook.com/RSorderSite?ref=tn_tnmn

Detailed info at: http://www.rsorder.com/profile/news/read/id/435

Fast delivery can be assured if you buy rs gold pay by Western Union at Rsorder!

Unknown said...

In my opinion, the author's idea is advisable.
I will make advertisement freely for your post,recommend it to my friends. www.4rsgold.com
Hope you all have a good time and revel in this outstanding update!