SpringFu

This extension …

Installation

  1. Install JRuby - see wiki.jruby.org for details.

  2. Install Rails and Warbler:

jruby -S gem install rails warbler
  1. Create Rails application:

jruby -S rails spring-on-rails

cd spring-on-rails
  1. Create Warbler configuration file:

jruby -S warble config
  1. Copy Spring and CommonsLogging jars into lib directory:

cp %PATH_TO_JARS_REPOSITORY%/spring.jar lib
cp %PATH_TO_REPOSITORY%/commons-logging.jar lib
  1. Create Spring context and fill it with Your Spring configuration:

mkdir config/spring/
vim config/spring/applicationContext.xml
  1. Copy web.xml template from Warbler into config directory:

cp %PATH_TO_GEMS_REPOSITORY%/warbler-%VERSION%/web.xml.erb config

vim config/web.xml.erb
  1. Add Spring listener into web.xml.erb file:

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/config/spring/applicationContext.xml</param-value>
</context-param>

<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
  1. Add gem dependency in your Rails config:

config.gem 'mszczytowski-spring-fu', :lib => 'spring-fu', :source => 'http://gems.github.com'
  1. Add spring-fu and others needed dependency in Warbler config:

config.gems += ["spring-fu", "activerecord-jdbcsqlite3-adapter", "activerecord-jdbc-adapter", "jdbc-sqlite3", "jruby-openssl"]
  1. Change database.yml to use jdbc connection:

adapter: jdbcsqlite3
url: jdbc:sqlite:/tmp/development.sqlite3
  1. Install gems:

jruby -S rake gems:install
  1. Create war file:

jruby -S rake war
  1. Deploy on Tomcat and have fun.

Usage

class YourController < ApplicationController

  spring_bean :useful_bean
  spring_bean :another_bean, :as => "new_name"

  def your_method
    useful_bean.do_sth_cool_in_spring_bean
    new_name.add(2, 2)
  end

end

Copyright © 2008 Maciej Szczytowski, released under the MIT license