SpringFu
This extension …
Installation
-
Install JRuby - see wiki.jruby.org for details.
-
Install Rails and Warbler:
jruby -S gem install rails warbler
-
Create Rails application:
jruby -S rails spring-on-rails
cd spring-on-rails
-
Create Warbler configuration file:
jruby -S warble config
-
Copy Spring and CommonsLogging jars into lib directory:
cp %PATH_TO_JARS_REPOSITORY%/spring.jar lib
cp %PATH_TO_REPOSITORY%/commons-logging.jar lib
-
Create Spring context and fill it with Your Spring configuration:
mkdir config/spring/
vim config/spring/applicationContext.xml
-
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
-
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>
-
Add gem dependency in your Rails config:
config.gem 'mszczytowski-spring-fu', :lib => 'spring-fu', :source => 'http://gems.github.com'
-
Add spring-fu and others needed dependency in Warbler config:
config.gems += ["spring-fu", "activerecord-jdbcsqlite3-adapter", "activerecord-jdbc-adapter", "jdbc-sqlite3", "jruby-openssl"]
-
Change database.yml to use jdbc connection:
adapter: jdbcsqlite3
url: jdbc:sqlite:/tmp/development.sqlite3
-
Install gems:
jruby -S rake gems:install
-
Create war file:
jruby -S rake war
-
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