JRuby: Apples and Oranges
-
Upload
engine-yard -
Category
Technology
-
view
1.734 -
download
2
description
Transcript of JRuby: Apples and Oranges
![Page 1: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/1.jpg)
JRubyApples AND Oranges
Thomas E. EneboEngine Yard Inc., www.jruby.org
Friday, November 5, 2010
![Page 2: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/2.jpg)
GOALS
• Get an idea of how JRuby can help you in day-to-day development
Friday, November 5, 2010
![Page 3: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/3.jpg)
Who Am I?
• JRuby Guy
• 4+ years as “day job” + few years as hobby
• Almost 10 years of Ruby
• 15+ years of Java
• Friendly
• Likes Beer
Friday, November 5, 2010
![Page 4: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/4.jpg)
http://www.pragprog.com/titles/jruby/using-jrubyFriday, November 5, 2010
![Page 5: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/5.jpg)
JRuby @ 10_000
• Implementation of Ruby runtime
• Runs on JVM (Java 5+)
• Open Source (CPL, GPL, LGPL)
• Integrates well with Java
Friday, November 5, 2010
![Page 6: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/6.jpg)
Ruby Quick Tour
• The relative feel between Java and Ruby
Friday, November 5, 2010
![Page 7: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/7.jpg)
Classespublic class Circle extends Shape { private final int radius;
public Circle(int radius) { this.radius = radius; } public int getRadius() { return radius; } public double getArea() { return Math.PI * Math.pow(radius,2); } public static void main(String[] a) { double area=new Circle(2).getArea(); System.out.println(area); }}
class Circle < Shape def initialize(radius) @radius = radius end attr_reader :radius
def area Math::PI*(@radius ** 2) endend
puts Circle.new(2).area
Friday, November 5, 2010
![Page 8: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/8.jpg)
Single Inheritance
public class Circle extends Shape { private final int radius;
public Circle(int radius) { this.radius = radius; } public int getRadius() { return radius; } public double getArea() { return Math.PI * Math.pow(radius,2); } public static void main(String[] a) { double area=new Circle(2).getArea(); System.out.println(area); }}
class Circle < Shape def initialize(radius) @radius = radius end attr_reader :radius
def area Math::PI*(@radius ** 2) endend
puts Circle.new(2).area
Same Thing
Friday, November 5, 2010
![Page 9: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/9.jpg)
Constructor
public class Circle extends Shape { private final int radius;
public Circle(int radius) { this.radius = radius; } public int getRadius() { return radius; } public double getArea() { return Math.PI * Math.pow(radius,2); } public static void main(String[] a) { double area=new Circle(2).getArea(); System.out.println(area); }}
class Circle < Shape def initialize(radius) @radius = radius end attr_reader :radius
def area Math::PI*(@radius ** 2) endend
puts Circle.new(2).area
Friday, November 5, 2010
![Page 10: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/10.jpg)
No Type Declarations
public class Circle extends Shape { private final int radius;
public Circle(int radius) { this.radius = radius; } public int getRadius() { return radius; } public double getArea() { return Math.PI * Math.pow(radius,2); } public static void main(String[] a) { double area=new Circle(2).getArea(); System.out.println(area); }}
class Circle < Shape def initialize(radius) @radius = radius end attr_reader :radius
def area Math::PI*(@radius ** 2) endend
puts Circle.new(2).area
Friday, November 5, 2010
![Page 11: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/11.jpg)
Dynamic Typing
• Ruby is Dynamically Typed
• Why we see no Type decls on variables
• Runtime type-checking (like Java casts)
• “If it waddles like a duck and quacks like a duck...”
Friday, November 5, 2010
![Page 12: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/12.jpg)
Instance Variables‘@’ == ‘this.’ and is mandatory
public class Circle extends Shape { private final int radius;
public Circle(int radius) { this.radius = radius; } public int getRadius() { return radius; } public double getArea() { return Math.PI * Math.pow(radius,2); } public static void main(String[] a) { double area=new Circle(2).getArea(); System.out.println(area); }}
class Circle < Shape def initialize(radius) @radius = radius end attr_reader :radius
def area Math::PI*(@radius ** 2) endend
puts Circle.new(2).area
Friday, November 5, 2010
![Page 13: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/13.jpg)
Point of No ReturnLast Expression is always return value
public class Circle extends Shape { private final int radius;
public Circle(int radius) { this.radius = radius; } public int getRadius() { return radius; } public double getArea() { return Math.PI * Math.pow(radius,2); } public static void main(String[] a) { double area=new Circle(2).getArea(); System.out.println(area); }}
class Circle < Shape def initialize(radius) @radius = radius end attr_reader :radius
def area Math::PI*(@radius ** 2) endend
puts Circle.new(2).area
Friday, November 5, 2010
![Page 14: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/14.jpg)
.new is just a class method!
public class Circle extends Shape { private final int radius;
public Circle(int radius) { this.radius = radius; } public int getRadius() { return radius; } public double getArea() { return Math.PI * Math.pow(radius,2); } public static void main(String[] a) { double area=new Circle(2).getArea(); System.out.println(area); }}
class Circle < Shape def initialize(radius) @radius = radius end attr_reader :radius
def area Math::PI*(@radius ** 2) endend
puts Circle.new(2).area
Friday, November 5, 2010
![Page 15: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/15.jpg)
Blocks/Closures• Pass an anonymous function to a method call
# Look mom...no boilerplate!my_open(file) do |io| first_line = io.gets # ...end
def my_open(file, mode='r') io = File.open(file) yield ioensure io.closeend
letters.group_by {|b| b.zip_code }
button.action_performed do exitend
Friday, November 5, 2010
![Page 16: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/16.jpg)
Modulesmodule Enumerable def find(if_none = nil) each { |o| return o if yield(o) } if_none end
# Many other methods not shown
def collect ary = [] each { |o| ary << yield(o) } ary endend
class MyTree include Enumerable
# tree impl not shown :)
def each # yield each element # in tree endend
dude = people.find { |person| person.id == 123 }
floats = [1,2].collect { |int| int.to_f } # => [1.0, 2.0]
Friday, November 5, 2010
![Page 17: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/17.jpg)
Everything is an Expression
class Color COLORS = {:red => 0xff0000, :green => 0x00ff00, :blue => 0x0000ff}
COLORS.each do |name, value| define_method(name) do value end endend
Friday, November 5, 2010
![Page 18: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/18.jpg)
Classes/Modules are openclass MyTree def each #... endend
#... later in source#... maybe even different file
class MyTree def debug #... endend
Friday, November 5, 2010
![Page 19: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/19.jpg)
JRuby Stuff
Friday, November 5, 2010
![Page 20: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/20.jpg)
Installation• Windows
• Others
• Unzip or Untar installation
• Add ‘bin’ directory to your PATHFriday, November 5, 2010
![Page 21: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/21.jpg)
Why not just a Jar?
• ‘jruby’ command-line launcher
• Works just like C Ruby launcher
• Many useful tools out of the box
• rspec, rake, rubygems, irb
Friday, November 5, 2010
![Page 22: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/22.jpg)
Integration with Java
• Call into Ruby from Java
• Java 6 Scripting
• Internal “Red Bridge” API
• Access Java classes from Ruby
• Call, Decorate, and Define in Ruby
Friday, November 5, 2010
![Page 23: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/23.jpg)
Access Ruby from Java• Red Bridge Shown...
ScriptingContainer container = new ScriptingContainer();
// ...
container.put("$revisions", new Revisions(args[0], args[1]));
List<Diff> f = (List<Diff>) container.runScriptlet("history");for (GitDiff file: f) { System.out.println("FILE: " + file.getPath()); System.out.println(file.getPatch());}
Friday, November 5, 2010
![Page 24: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/24.jpg)
Use Case: Scripting Java
• One-off scripts are easy as opening an editor
• Not everything must be an IDE project
• Easy to play with technology
Friday, November 5, 2010
![Page 25: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/25.jpg)
Demo: Scripting Java
Friday, November 5, 2010
![Page 26: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/26.jpg)
Demo: Eye Candy
Friday, November 5, 2010
![Page 27: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/27.jpg)
Use-case: Build tools
• Leverage Ruby Tooling to make building project more manageable
Friday, November 5, 2010
![Page 28: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/28.jpg)
Ant + Rake
• Ant is 800 pound Gorilla of Java
• Declarative and a little Dumb but Dependable
• Used Everywhere
Friday, November 5, 2010
![Page 29: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/29.jpg)
Ant + Rake
• Rake is Orangutang of Ruby
• Like Make or Ant
• ....but with Ruby for Imperative Goodness
Friday, November 5, 2010
![Page 30: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/30.jpg)
Ant + Rake
• Call Rake From Ant
• Call tasks
• Rake tasks as Ant target dependencies
• Call Ant From Rake
• Ditto!
• Mix and Match
Friday, November 5, 2010
![Page 31: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/31.jpg)
Rake Calling Ant Tasks
require 'rake'require 'ant'
task :init do ant.mkdir :dir => 'build'end
task :compile => :init do ant.javac :destdir => 'build' do src { pathelement :location => 'src' } endend
task :test => :some_ant_task
Friday, November 5, 2010
![Page 32: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/32.jpg)
Rake Calling Ant
task :call_ant do ant '-f my_build.xml its_in_ant'end
task :ant_import do ant_import # you could also do this outsideend
task :compile => [:ant_import, :its_in_ant] do # Do some compilationend
Friday, November 5, 2010
![Page 33: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/33.jpg)
Rake from Ant
<?xml version="1.0" encoding="UTF-8"?><project name="foobar" default="default" basedir="."> <description>Builds, tests, and runs the project foobar. </description>
<target name="load-rake-task"> <taskdef name="rake" classname="org.jruby.ant.Rake"/> </target>
<target name="default" depends="load-rake-task"> <rake task="jar"/> </target>
...</project>
Friday, November 5, 2010
![Page 34: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/34.jpg)
Ant Calling Rake Tasks
<?xml version="1.0" encoding="UTF-8"?>
<project name="foobar" default="top-level" basedir="."> <description>Builds the project foobar.</description>
<taskdef name="rakeimport" classname="org.jruby.ant.RakeImport"/> <rakeimport/>
<target name="top-level" depends="its_in_rake" />
<target name="its_in_ant"> <echo message="ant: its_in_ant"/> </target></project>
Friday, November 5, 2010
![Page 35: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/35.jpg)
Maven?
• Maven support is being worked on
• Are you a maven user?
• Any features you want?
Friday, November 5, 2010
![Page 36: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/36.jpg)
Use Case: Testing
“#JRuby's Java integration is so awesome I will never write another line of java unit test code... it's all jruby
(if I can help it)” -Jay ‘obviously a JRuby user’ McGaffigan
Friday, November 5, 2010
![Page 37: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/37.jpg)
JTestr
• Bridge to make it easy to use Ruby testing tech.
• test/unit, rspec, mocha, ...
• Integrates with both Ant and Maven
• Allows mocking of non-final Java class/method
• Written by Ola Bini (previous speaker)
• Ask him questions later :)
Friday, November 5, 2010
![Page 38: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/38.jpg)
JTestr Example
my_project/ build.xml! test/ test_hashmap.rb hashmap_spec.rb lib/ jtestr.jar src/ <your source ;) >
Friday, November 5, 2010
![Page 39: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/39.jpg)
JTestr in Ant
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="jar" name="JRuby"> <target name="test" description="Runs all tests"> <taskdef name="jtestr" classname="org.jtestr.ant.JtestRAntRunner" classpath="lib/jtestr.jar"/> <jtestr/> </target></project>
Friday, November 5, 2010
![Page 40: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/40.jpg)
Ruby’s test/unit
class HashMapTests < Test::Unit::TestCase def setup @map = java.util.HashMap.new end
def test_that_an_entry_can_be_added @map.put "foo", "bar" assert_equal "bar", @map.get("foo") end
def test_empty_key_set_iterator_throws_exception assert_raises(java.util.NoSuchElementException) do @map.key_set.iterator.next end endend
test/test_hashmap.rb
Friday, November 5, 2010
![Page 41: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/41.jpg)
Ruby’s rspectest/hashmap_spec.rb
describe "An empty", HashMap do before :each do @hash_map = java.util.HashMap.new end
it "should be able to add an entry to it" do @hash_map.put "foo", "bar" @hash_map.get("foo").should == "bar" end
it "should not be empty after an entry has been added to it" do @hash_map.put "foo", "bar" @hash_map.should_not be_empty end
it "should be empty" do @hash_map.should be_empty endend
Friday, November 5, 2010
![Page 42: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/42.jpg)
OUTPUT!
Buildfile: /Users/enebo/work/jtestr/build.xml
test: [jtestr] Other TestUnit: 2 tests, 0 failures, 0 errors [jtestr] [jtestr] Other Spec: 3 examples, 0 failures, 0 errors [jtestr] [jtestr] Total: 5 tests, 0 failures, 0 errors, 0 pending [jtestr]
BUILD SUCCESSFULTotal time: 9 seconds
% ant test
Friday, November 5, 2010
![Page 43: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/43.jpg)
Use Case: Web Development
• Ruby on Rails
• Full-stack web framework
• Model View Controller (MVC)
• Convention over Configuration
• Don’t Repeat Yourself (DRY)
• Agile Programming
Friday, November 5, 2010
![Page 44: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/44.jpg)
Rails Quick Tour
Friday, November 5, 2010
![Page 45: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/45.jpg)
Getting Started is easy% rails new myapp -m http://jruby.org/rails3.rb
myapp/ Gemfile app/ controllers/ helpers/ mailers/ models/ views/ db/ log/ test/ config/ public/ Rakefile lib/
• All apps the have same layout
• Totally self-contained
• Type ‘rails server’ and you are in development mode
• Code and see changes live*
• Simple generation scripts
Friday, November 5, 2010
![Page 46: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/46.jpg)
Migrations
• DB-agnostic DSL for managing Schemas
• Each migration a committable file in ‘db’ dirclass CreatePeople < ActiveRecord::Migration def self.up create_table :people do |t| t.string :last_name t.string :first_name t.integer :age t.timestamps end end
def self.down drop_table :people endend
Friday, November 5, 2010
![Page 47: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/47.jpg)
ActiveModel
• Model single-sources from DB metadata
• Pluralizes model name and looks for table
• Grabs meta data and at runtime adds
• fields + methods
class Person < ActiveRecord::Base # Models really start out this smallend
Friday, November 5, 2010
![Page 48: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/48.jpg)
ActiveModel
class Person < ActiveRecord::Base
validates_presence_of :last_name validates_length_of :age, :in => 0..120 end
• Validations
• Serializationperson.to_jsonperson.to_xml
• Much More...
Friday, November 5, 2010
![Page 49: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/49.jpg)
ActiveRelation
• Composable Relational Algebra DSL
• LazyPerson.where(:last_name => "enebo").where(:first_name => "thomas")
# All Enebo'sall_enebos = Person.where(:last_name => "enebo")
# Yarrr...there can be only oneme = all_enebos.where(:first_name => "thomas")
Friday, November 5, 2010
![Page 50: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/50.jpg)
Scopes in ActiveRecord
class Person < ActiveRecord::Base scope :enebos, where(:last_name => "enebo")end
# In your controllerenebos = Person.enebos.order(:first_name)
• Save useful relations as a name in your model!
Friday, November 5, 2010
![Page 51: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/51.jpg)
Routes MyApp::Application.routes.draw do resources :people, :except => [:index]end
Verb Path Action Used for
GET /comments index display a list of all comments
GET /comments/new new return a form for creating a comment
POST /comments create create a new comment
GET /comments/:id show display a comment
GET /comments/:id/edit edit return a form for editing a comment
PUT /comments/:id update update a comment
DELETE /comments/:id destroy delete a commentFriday, November 5, 2010
![Page 52: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/52.jpg)
Controllers
class PeopleController < ApplicationController respond_to :html respond_to :json, :only => :show
def show @person = Person.find_by_id params[:id] respond_with @person end
def create @person = Person.new(params[:person]) @person.save respond_with @person endend
Friday, November 5, 2010
![Page 53: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/53.jpg)
Views
• ERB is the JSP of Rails
• Rails generates lots of helpers like *_path to not have brittle URLs
• Partials for fragment rendering
<b>Name:</b><%= @person.name %>
<% if @person.age > 21 %> <b>Age:</b><%= @person.age %><% end %>
<%= link_to 'Edit', edit_person_path(@person) %> |<%= link_to 'Back', people_path %>
Friday, November 5, 2010
![Page 54: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/54.jpg)
JRuby on Rails Deployment
• Deploy to any Java App Server
• warbler gem to generate .war files
• Use Trinidad or Glassfish Gem for Ruby style deployment
• Start up server in directory...done.
Friday, November 5, 2010
![Page 55: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/55.jpg)
Rails and Java
• Seamlessly use Java business objects in Rails project
• People hybridize Java web apps by adding Rails to the project for new pieces
• Have JSPs <-> ERBs mix together
• taglibs to render ERBs in JSPs
Friday, November 5, 2010
![Page 56: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/56.jpg)
Conclusions
• Ruby is easy to learn for Java programmers
• Easy to mix Ruby+Java
• Useful Productivity Frameworks and Libraries
• Rails, Rake, JTestr, ...
• One more tool for Java programmer’s toolbelt
Friday, November 5, 2010
![Page 57: JRuby: Apples and Oranges](https://reader037.fdocuments.net/reader037/viewer/2022102901/5550fb83b4c90572478b4aa9/html5/thumbnails/57.jpg)
Thank You
• twitter: tom_enebo
• website: http://www.jruby.org/
• book: www.pragprog.com/titles/jruby/using-jruby
• JtestR: http://jtestr.codehaus.org/
Friday, November 5, 2010