Rails On Spring

43
Rails on Spring Using JRuby as the Secret Sauce Brian Sam-Bodden

description

A look at the impossible, the marriage between Ruby and Spring.integrallis.com

Transcript of Rails On Spring

Page 1: Rails On Spring

Rails on SpringUsing JRuby as the Secret Sauce

Brian Sam-Bodden

Page 2: Rails On Spring

Agenda

The State of Java and JEE

Ruby on Rails to the Rescue

Ruby makes Rails possible

The Spring Framework

Page 3: Rails On Spring

Agenda

JRuby - Ruby on Steroids

JRuby on Rails

JRuby for Rapid Spring Prototyping

JRuby on Rails and Spring

Page 4: Rails On Spring

The State of Java and JEE

Page 5: Rails On Spring

Java & JEE

the most prevalent language

the most complete enterprise platform

a rich ecosystem of web frameworks

a vibrant open source community

Page 6: Rails On Spring

plagued by mediocre web frameworks

not well suited for rapid prototyping

in need of a dynamic language web framework

one level of abstraction too low for the web

Java & JEE

Page 7: Rails On Spring

Who could help Java on the Web Tier?

Page 8: Rails On Spring

Ruby on Rails

a revolutionary web framework

complete MVC solution

fast prototyping

killer AJAX support

Page 9: Rails On Spring

a DSL for the web

leading the pack on the web 2.0 front

born from a product, not a committee

a vibrant open source community

Ruby on Rails

Page 10: Rails On Spring

Ruby makes Rails possible

Page 11: Rails On Spring

Rubyis...

✓Object-Oriented

✓Reflective ✓Dynamic

✓ Interpreted

✓General Purpose

✓ Multi-paradigm

✓ Garbage-collected

✓Elegant

Page 12: Rails On Spring

The Spring Framework A breath of fresh air for Java

Page 13: Rails On Spring

The Spring Framework

is a lightweight IoC and AOP framework

is the leading framework to build enterprise applications

is one level of abstraction up from JEE

is a layered Java/J2EE application framework

Page 14: Rails On Spring

The Spring Framework

let’s you use all of the power of JEE

integrates seamlessly with Hibernate

POJO-based development keeps your code clean

harnesses the power of IoC and AOP

Page 15: Rails On Spring

The Spring Framework

Spring 2.0 supports dynamic languages

support for JRuby, Groovy and BeanShell

beans can be backed by dynamic languages

scripted MVC controllers

Page 16: Rails On Spring

JRubyRuby on Steroids

Page 17: Rails On Spring

JRuby

100% pure-Java implementation of Ruby

brings Ruby to the JVM

started in 2002, now under Sun’s auspice

open source with a growing community

Page 18: Rails On Spring

JRuby

call Ruby from Java or Java from Ruby

lots of sub-projects emerging

better scalability with native threading

native unicode support

Page 19: Rails On Spring

JRuby

specialized JRuby offerings are appearing...

Page 20: Rails On Spring

The good gets better

Page 21: Rails On Spring

JRuby on Rails

the agility of rails - the scalability of Java

JRuby likely to surpass Ruby in speed

sneak Ruby and RoR into the enterprise!

Page 22: Rails On Spring

JRuby on Rails

Page 23: Rails On Spring

JRuby on Rails

Page 24: Rails On Spring

JRuby on Rails

JEE servers are good at scaling up

no more multi-process management

use JRuby “multi-VM” support

leverage the maturity of the JVM and JEE servers

Page 25: Rails On Spring

JRuby on Rails

deploy your Rails app as a WAR

leverage JDBC from ActiveRecord

Page 26: Rails On Spring

JRubyFor Rapid Spring Prototyping

...one way of sneaking Ruby in through the back door

Page 27: Rails On Spring

JRuby+Spring RAD

a simple example by the folks at jobster

use JRuby for rapid prototyping

Spring controller that delegates to a JRuby controller

JRuby controllers live alongside your JSPs

Page 28: Rails On Spring

JRuby+Spring RAD

Simple JRuby controller

Page 29: Rails On Spring

JRuby+Spring RAD

JSP view provides input to the Ruby controller

Page 30: Rails On Spring

JRuby+Spring RAD

JSP view provides input to the Ruby controller

Page 31: Rails On Spring

JRuby+Spring RAD

this experimental library supports:

✓access to Spring beans from JRuby code

✓ access to Hibernate queries

Page 32: Rails On Spring

The Perfect Pairing for a Java ShopJRuby on Rails + Spring

Page 33: Rails On Spring

JRoR on Spring

✓use rails-integration plugin

✓ expose WebApplicationContext in a RoR controller

Chris Nelson’s work

✓include Spring - Spring plugin for JRuby

Page 34: Rails On Spring

JRoR on Spring

✓install goldspike rails-integration plugin on you JRoR app

✓ rake war:standalone:create to package a WAR with:

➡Your RoR app

➡JRuby and Rails libraries

Page 35: Rails On Spring

JRoR on Spring

rake war:standalone:create in action:

Page 36: Rails On Spring

JRoR on Spring

generated WARs work on many servers:

✓Tomcat

✓Jetty

✓Glassfish

✓JBoss

Page 37: Rails On Spring

JRoR on Spring✓ add Chris’ Spring module:

Page 38: Rails On Spring

JRoR on Spring

✓Add Spring application

✓Expand the generated WAR

➡Application Code

➡ Libraries (Jars)

➡Config Files

Page 39: Rails On Spring

JRoR on Spring

✓ access your Spring beans from a RoR controller

Page 40: Rails On Spring

JRoR on Spring

✓add a new face to your Spring applications

✓ leverage thousands of open source projects

✓leverage the good parts of JEE like JDBC and JMS

Page 41: Rails On Spring

ResourcesJRuby

www.jruby.orgrubyforge.org/projects/jruby-extras

JRuby Rails Integrationwww.headius.com/jrubywiki/index.php/Rails_Integration

headius.blogspot.com/2006/11/advanced-rails-deployment-with-jruby.html

RAD Spring Prototyping with JRubythebogles.com/blog/projects/ruby-on-spring/

www.botspiritcompany.com/src/springruby/example_ruby_spring.html

Chris Nelson’s Workmysterycoder.blogspot.com/2007/06/spring-jruby.html

mysterycoder.blogspot.com/2007/06/include-spring.html

Page 42: Rails On Spring

Books by Integrallis

Yes, they are all Java books :-(

Page 43: Rails On Spring

Thanks!