SlideShare ist ein Scribd-Unternehmen logo
1 von 71
Downloaden Sie, um offline zu lesen
From Java...to Rails


             Nick Sieger
             @nicksieger
Are you happy with
your development pace


        ?
?
How do you get to a place
   where it’s better?
Introduce
Language
Replace JSF with
  *Anything*
throw away
Built environment
    long-running projects
    with legacy codebases
Sagrada Família,
Barcelona, Spain
passion
                     facade


   nativity
   facade


scaffolded interior
Ryugyong Hotel,
2004     North Korea     2011
seismic retrofit
Szkieletor,
Kraków, Poland
Metaphor    Use Ruby, JRuby, and Rails to...

 Sagrada    • Build new facade faster
 Familia    • Scaffolding during refactoring

Ryugyong
         • Revive a project with a new face
  Hotel

 Seismic    • Reinforce business rules with a DSL
 retrofit    • Harden security


Szkieletor • Find novel uses for abandoned code
Metaphor    Use Ruby, JRuby, and Rails to...

 Sagrada    • Build new facade faster
 Familia    • Scaffolding during refactoring

Ryugyong
         • Revive a project with a new face
  Hotel

 Seismic    • Reinforce business rules with a DSL
 retrofit    • Harden security


Szkieletor • Find novel uses for abandoned code
Metaphor    Use Ruby, JRuby, and Rails to...

 Sagrada    • Build new facade faster
 Familia    • Scaffolding during refactoring

Ryugyong
         • Revive a project with a new face
  Hotel

 Seismic    • Reinforce business rules with a DSL
 retrofit    • Harden security


Szkieletor • Find novel uses for abandoned code
Metaphor    Use Ruby, JRuby, and Rails to...

 Sagrada    • Build new facade faster
 Familia    • Scaffolding during refactoring

Ryugyong
         • Revive a project with a new face
  Hotel

 Seismic    • Reinforce business rules with a DSL
 retrofit    • Harden security


Szkieletor • Find novel uses for abandoned code
Metaphor    Use Ruby, JRuby, and Rails to...

 Sagrada    • Build new facade faster
 Familia    • Scaffolding during refactoring

Ryugyong
         • Revive a project with a new face
  Hotel

 Seismic    • Reinforce business rules with a DSL
 retrofit    • Harden security


Szkieletor • Find novel uses for abandoned code
Biological evolution
    new replaces old over time
Strangler Fig
github.com/nicksieger/refactoring-to-rails
Before we begin...
Test Plan
Don’t leave home without it
gembundler.com
Bundler

source :rubygems

group   :test do
  gem   'rspec-rails'
  gem   'cucumber-rails'
  gem   'capybara'
end
Feature: Owners

  Scenario: Add New Owner
    Given I am on the new owner page
    When I fill in the following:
      | First name | Dan          |
      | Last name | Wood          |
      | Address    | 123 Main St |
      | City       | Anywhere     |
      | Telephone | 5555555       |
    And I press "Add Owner"
    Then I should see "Owner Information" within "h2"
    And I should see "Dan Wood"
Foot in the door
    Sneaking Ruby in
JRuby-Rack
org.jruby.rack:jruby-rack
Servlet
Java          Ruby




 /*          /rack/*


       App
<listener>
  <listener-class>
    org.jruby.rack.RackServletContextListener
  </listener-class>
</listener>

<servlet>
  <servlet-name>rack</servlet-name>
  <servlet-class>org.jruby.rack.RackServlet</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>rack</servlet-name>
  <url-pattern>/rack/*</url-pattern>
</servlet-mapping>
# WEB-INF/config.ru
require 'sinatra'

if development?
  require 'sinatra/reloader'
  use Rack::ShowExceptions
end

require 'app'

set :run, false
run Sinatra::Application
# app.rb
get '/rack/' do
  '<h1>Sinatra</h1>'
end
REST
Not just APIs...
URIs + HREFs
 Architecture of the Web
<a href="/vets.xml">View as XML</a>
<a href="/rack/vets.xml">View as XML</a>
In JSPs

<jruby-rack:rails path="/rack/vets" params="layout=none"/>
Red Green Refactor
    Continuous improvement
Interceptor pattern
     Partial strangulation
Filter




                        /owners    Java/
/   /vets     /owners    /1/pets   Spring

            App
Filter



/   /vets                          Ruby

                        /owners    Java/
/   /vets     /owners    /1/pets   Spring

            App
SpringPetclinic::Application.routes.draw do

  root :to => "welcome#index"

  resources :vets

end
Rails      Java
Request
          response   response


   /      200 OK      (N/A)


          404 Not
/owners              200 OK
           Found
Re-use views
   JSP-in-ERB
<%= request.render '/WEB-INF/jsp/header.jsp' %>

<%= yield %>

<%= request.render '/WEB-INF/jsp/footer.jsp' %>
Re-use models
  Hibernate + ActiveModel
# app/models/owner.rb
java_import org.springframework.samples.petclinic.Owner
# app/models/owner.rb
java_import org.springframework.samples.petclinic.Owner

class Owner
  extend ActiveModel::Naming
  include ActiveModel::Validations
  include ActiveModel::Conversion




end
# app/models/owner.rb
java_import org.springframework.samples.petclinic.Owner

class Owner
  extend ActiveModel::Naming
  include ActiveModel::Validations
  include ActiveModel::Conversion

  validates_presence_of :first_name, :last_name,
    :address, :city, :telephone
  validates_format_of :telephone, :with => /[-0-9.+ ]+/,
    :message => "..."
end
<%# app/views/owner/_form.html.erb %>
<%= form_for @owner do |f| %>

   <%= f.label :first_name %>
   <br/>
   <%= f.text_field :first_name %>

   <%= f.label :last_name %>
   <br/>
   <%= f.text_field :last_name %>

   <%# ... %>
<% end -%>
<%# app/views/owner/_form.html.erb %>
<%= form_for @owner do |f| %>
            @owner
   <%= f.label :first_name %>
   <br/>
   <%= f.text_field :first_name %>

   <%= f.label :last_name %>
   <br/>
   <%= f.text_field :last_name %>

   <%# ... %>
<% end -%>
Rails takes over
    Final strangulation
$ rails new petclinic --skip-active-record
$ mvn org.jruby.plugins:jruby-rake-plugin:classpath
# config/initializers/classpath.rb
module Maven
  extend self

  CLASSPATH = [
    "#{BASEDIR}/target/classes",
    "#{ENV['HOME']}/.m2/.../org.springframework.core-3.0.0.RELEASE.jar",
    # lots of jars here...
  ]

  def set_classpath
    require 'java'
    CLASSPATH.each {|p| $CLASSPATH << p }
  end
end
Maven.set_classpath

module Spring
  SPRING_XML_CONFIG_FILES = [
    'classpath:applicationContext.xml'
  ].to_java :string      # creates a String[]

  CONTEXT = ClassPathXmlApplicationContext.new(
    SPRING_XML_CONFIG_FILES)
end
Warbler
INSTALL   gem install warbler
# config/warble.rb
Warbler::Config.new do |config|

  require 'config/initializers/classpath'
  config.java_libs += Maven.jar_files

  config.java_classes = FileList["target/classes/**/*"]

end
$ warble executable war
Creating refactoring-to-rails.war
$ java -jar refactoring-to-rails.war
Hollow out the tree
JRuby T-Shirts!
Stop by booth #5605
Party Tue 6:30pm
http://ey.io/oeuot1
➡ Script Bowl
     Nic Williams
     Wed 8:30 AM–Hilton Grand Ballroom B

➡ Accelerate Your Business and Aim for the
  Cloud with Java and JRuby
     Jacob Lehrbaum, Mike Piech
     Wed 3:00 PM–Parc 55 Embarcadero

➡ Real World JRuby
     Charles Nutter, Thomas Enebo
     Wed 4:30 PM–Parc 55 Market Street
Images
http://www.flickr.com/photos/john_mcclumpha/4138419594/
http://www.flickr.com/photos/phil_shirley/4500893932/
http://www.flickr.com/photos/y_i/2330044065/
http://www.flickr.com/photos/herzogbr/462383777/
http://en.wikipedia.org/wiki/File:Sagrada_Familia_01.jpg
http://www.flickr.com/photos/koocheekoo/38407225/
http://www.flickr.com/photos/27649557@N07/5000528445/
http://www.flickr.com/photos/gpaumier/446059442/
http://www.flickr.com/photos/ilm/12831049/
http://upload.wikimedia.org/wikipedia/commons/9/95/Ryugyong_hotel_01.jpg
http://upload.wikimedia.org/wikipedia/commons/7/78/
Ryugyeong_Hotel_on_February_2011.jpg
http://en.wikipedia.org/wiki/File:ExteiorShearTruss.jpg
http://en.wikipedia.org/wiki/File:ExtReenfDetail.jpg
http://en.wikipedia.org/wiki/File:Szkieleteor_in_krakow.JPG
http://www.flickr.com/photos/epingchris/5110376533/
http://www.flickr.com/photos/bazylek/3194294047/
http://www.flickr.com/photos/58847482@N03/5920653295/
http://www.flickr.com/photos/nancybaym/3828905896/
http://www.flickr.com/photos/anitagould/5501316782/

Weitere ähnliche Inhalte

Ähnlich wie From java to rails

Firefox3.5 And Next
Firefox3.5 And NextFirefox3.5 And Next
Firefox3.5 And Next
Channy Yun
 
Getting started with Cloud Foundry
Getting started with Cloud FoundryGetting started with Cloud Foundry
Getting started with Cloud Foundry
Lode Vermeiren
 
Azri solutions leaner techniques for faster portals get drupalled
Azri solutions leaner techniques for faster portals   get drupalledAzri solutions leaner techniques for faster portals   get drupalled
Azri solutions leaner techniques for faster portals get drupalled
OpenSourceIndia
 
Azri solutions leaner techniques for faster portals get drupalled
Azri solutions leaner techniques for faster portals   get drupalledAzri solutions leaner techniques for faster portals   get drupalled
Azri solutions leaner techniques for faster portals get drupalled
suniltomar04
 
Rajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitesRajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websites
OpenSourceIndia
 
Rajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitesRajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websites
suniltomar04
 
IPv6 Adoption in the RIPE NCC Service Region
IPv6 Adoption in the RIPE NCC Service RegionIPv6 Adoption in the RIPE NCC Service Region
IPv6 Adoption in the RIPE NCC Service Region
RIPE NCC
 
Dynamics NAV, Windows Azure & Windows Phone 7, Eric Wauters
Dynamics NAV, Windows Azure & Windows Phone 7, Eric WautersDynamics NAV, Windows Azure & Windows Phone 7, Eric Wauters
Dynamics NAV, Windows Azure & Windows Phone 7, Eric Wauters
dynamicscom
 
Divyanshu open stack presentation -osi-ppt
Divyanshu open stack presentation -osi-pptDivyanshu open stack presentation -osi-ppt
Divyanshu open stack presentation -osi-ppt
OpenSourceIndia
 
Divyanshu open stack presentation -osi-ppt
Divyanshu open stack presentation -osi-pptDivyanshu open stack presentation -osi-ppt
Divyanshu open stack presentation -osi-ppt
suniltomar04
 
Vineet Choudhry Portfolio
Vineet Choudhry PortfolioVineet Choudhry Portfolio
Vineet Choudhry Portfolio
Rakesh Ranjan
 
『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ
Masaaki HIROSE
 

Ähnlich wie From java to rails (20)

Firefox3.5 And Next
Firefox3.5 And NextFirefox3.5 And Next
Firefox3.5 And Next
 
Scalable JavaScript Application Architecture
Scalable JavaScript Application ArchitectureScalable JavaScript Application Architecture
Scalable JavaScript Application Architecture
 
Getting started with Cloud Foundry
Getting started with Cloud FoundryGetting started with Cloud Foundry
Getting started with Cloud Foundry
 
Getting started with Cloud Foundry
Getting started with Cloud FoundryGetting started with Cloud Foundry
Getting started with Cloud Foundry
 
Webinar: Top 5 Mistakes Your Don't Want to Make When Moving to the Cloud
Webinar: Top 5 Mistakes Your Don't Want to Make When Moving to the CloudWebinar: Top 5 Mistakes Your Don't Want to Make When Moving to the Cloud
Webinar: Top 5 Mistakes Your Don't Want to Make When Moving to the Cloud
 
Azri solutions leaner techniques for faster portals get drupalled
Azri solutions leaner techniques for faster portals   get drupalledAzri solutions leaner techniques for faster portals   get drupalled
Azri solutions leaner techniques for faster portals get drupalled
 
Azri solutions leaner techniques for faster portals get drupalled
Azri solutions leaner techniques for faster portals   get drupalledAzri solutions leaner techniques for faster portals   get drupalled
Azri solutions leaner techniques for faster portals get drupalled
 
AMP110 Microsoft Access Macros
AMP110 Microsoft Access MacrosAMP110 Microsoft Access Macros
AMP110 Microsoft Access Macros
 
Hacking Rapidshare
Hacking RapidshareHacking Rapidshare
Hacking Rapidshare
 
OSC11 - The future is now for all your Business Processes
OSC11 - The future is now for all your Business ProcessesOSC11 - The future is now for all your Business Processes
OSC11 - The future is now for all your Business Processes
 
Rajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitesRajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websites
 
Rajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websitesRajashekaran vengalil building cross browser html5 websites
Rajashekaran vengalil building cross browser html5 websites
 
IPv6 Adoption in the RIPE NCC Service Region
IPv6 Adoption in the RIPE NCC Service RegionIPv6 Adoption in the RIPE NCC Service Region
IPv6 Adoption in the RIPE NCC Service Region
 
Dynamics NAV, Windows Azure & Windows Phone 7, Eric Wauters
Dynamics NAV, Windows Azure & Windows Phone 7, Eric WautersDynamics NAV, Windows Azure & Windows Phone 7, Eric Wauters
Dynamics NAV, Windows Azure & Windows Phone 7, Eric Wauters
 
クックパッドでのemr利用事例
クックパッドでのemr利用事例クックパッドでのemr利用事例
クックパッドでのemr利用事例
 
Divyanshu open stack presentation -osi-ppt
Divyanshu open stack presentation -osi-pptDivyanshu open stack presentation -osi-ppt
Divyanshu open stack presentation -osi-ppt
 
Divyanshu open stack presentation -osi-ppt
Divyanshu open stack presentation -osi-pptDivyanshu open stack presentation -osi-ppt
Divyanshu open stack presentation -osi-ppt
 
Vineet Choudhry Portfolio
Vineet Choudhry PortfolioVineet Choudhry Portfolio
Vineet Choudhry Portfolio
 
Using Database Constraints Wisely
Using Database Constraints WiselyUsing Database Constraints Wisely
Using Database Constraints Wisely
 
『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ『Ficia』インフラとPerlにまつわるエトセトラ
『Ficia』インフラとPerlにまつわるエトセトラ
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

From java to rails