Your SlideShare is downloading. ×
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010

2,658

Published on

Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010

Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,658
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
32
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Getting Started with Rails on GlassFish (Hands-on Lab) Arun Gupta, Java EE & GlassFish Guy, Oracle Corp blogs.sun.com/arungupta, @arungupta
  • 2. What this session is not ? • Not a GlassFish tutorial • Not a Rails tutorial • Not a MySQL tutorial
  • 3. Software Installed ? • JDK 1.6.0_XX • NetBeans 6.8 (“All” or “Ruby” bundle) • JRuby 1.4.0 • MySQL Community Server 15 minutes
  • 4. What is GlassFish ?
  • 5. What is GlassFish ?
  • 6. GlassFish: It's a Community!
  • 7. GlassFish: Lives on java.net Since 2005
  • 8. GlassFish: Open Source and Production Quality
  • 9. GlassFish: Reference Implementation Java EE 5 Java EE 6
  • 10. GlassFish v3
  • 11. What is Ruby-on-Rails ? • Full-stack Web development framework in Ruby • Popularly known as Rails • Current Version: Rails 2.3.5 • Rails 3.0 coming
  • 12. Ruby-on-Rails MVC Incoming Request Web Server ActionController (Controller) ActiveRecord ActionView xxx_controller.rb (Model) (View) xxx.rb .rhtml .erb Database
  • 13. Rails Design Principles • Convention over Configuration (CoC) • Common cases easily served • Encourages standard practices • Everything simpler and smaller • Don't Repeat Yourself (DRY) • Framework written around minimizing repetition • Agile Development • No compile, redeploy, restart cycles • Testing built into the framework
  • 14. JRuby • Ruby interpreter written in Java • Current Version: 1.4.0 • 1.5 RC coming soon • Ruby 1.8.7 compatible • Some Ruby 1.9 support • --1.9 flag (80%)
  • 15. JRuby • Solid performance ( ͋Ruby 1.9) • Startup is poor, execution usually better than 1.9 • Runs native threads • Foreign Function Interface (FFI)for C libraries • Adopted from Rubinius, CRuby gem • Runs Rails great!
  • 16. Install JRuby • CLI: Download & Unzip “jruby- bin-1.4.0.zip” from jruby.org • NetBeans “All” or “Ruby” bundle (pre-installed)
  • 17. Install Rails & GlassFish Gem • CLI: “jruby -S gem install rails glassfish” • NetBeans: Tools -> Ruby Gems -> New Gems • Rails pre-installed • Search “glassfish”, Install 5 minutes
  • 18. Start Database • Mac/Linux: mysqld_safe --user root • Windows: bin/mysqld-nt --user root • Installed as service ? 2 minutes
  • 19. Install Database Adapter “jruby -S gem install activerecord-jdbcmysql-adapter” 2 minutes
  • 20. Create a Rails App jruby -S rails helloworld -d mysql cd helloworld jruby script/generate jdbc jruby -S rake db:create 5 minutes
  • 21. Run the App cd helloworld jruby -S glassfish 5 minutes
  • 22. Add CRUD features jruby script/generate scaffold book title:string author:string 5 minutes
  • 23. Model View Controller exists app/models/ exists app/controllers/ exists app/helpers/ create app/views/books exists app/views/layouts/ exists test/functional/ exists test/unit/ create test/unit/helpers/ exists public/stylesheets/ create app/views/books/index.html.erb create app/views/books/show.html.erb create app/views/books/new.html.erb create app/views/books/edit.html.erb create app/views/layouts/books.html.erb create public/stylesheets/scaffold.css create app/controllers/books_controller.rb create test/functional/books_controller_test.rb create app/helpers/books_helper.rb create test/unit/helpers/books_helper_test.rb route map.resources :books dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/book.rb create test/unit/book_test.rb create test/fixtures/books.yml create db/migrate create db/migrate/20100310221044_create_books.rb
  • 24. Generate Database Table jruby -S rake db:migrate == CreateBooks: migrating ============================ -- create_table(:books) -> 0.1690s -> 0 rows == CreateBooks: migrated (0.1710s) ===================== 2 minutes
  • 25. Sample Output 5 minutes
  • 26. GlassFish Gem http://rubyforge.org/projects/glassfishgem/
  • 27. GlassFish Gem: Options jruby -S glassfish -h -c: change the context root -e: environment -d: runs as daemon -P: location of PID file -l: log file location -log-level: Logging level (0-7)
  • 28. GlassFish Gem: Recipes
  • 29. Why Rails on GlassFish ? - Agile
  • 30. Why ? - Easy prototyping, yet powerful
  • 31. Why ? - Best of both worlds
  • 32. Why ? - Database Connection Pooling
  • 33. Why ? - Management
  • 34. Why ? - Monitoring
  • 35. Directory-based deployment: How ? asadmin start-domain asadmin deploy --property "jruby.home=JRUBY_HOME" helloworld Complete Absolute Path 7 minutes
  • 36. Directory-based deployment: Recipes
  • 37. Not Just Rails ... http://blogs.sun.com/arungupta/entry/totd_53_scaffold_in_merb http://blogs.sun.com/arungupta/entry/totd_80_sinatra_crud_application
  • 38. And more ... http://weblogs.java.net/blog/vivekp/archive/2009/04/plugin_any_ruby.html
  • 39. Deployment Options http://blogs.sun.com/arungupta/entry/totd_81_how_to_use http://blog.headius.com/2009/04/apache-jruby-rails-glassfish-easy.html
  • 40. Rails on GlassFish: WAR Deployment
  • 41. WAR Deployment: How ? jruby -S gem install warbler jruby -S warble asadmin deploy xxx.war 7 minutes http://blogs.sun.com/arungupta/entry/totd_73_jruby_and_glassfish
  • 42. WAR Deployment: How in NetBeans ?
  • 43. WAR Deployment: Packaging
  • 44. Rails on GlassFish: Update Center
  • 45. NetBeans: Develop with Pleasure 10 minutes http://blogs.sun.com/arungupta/entry/screencast_26_develop_run_debug
  • 46. Rails Monitoring • Basic Monitoring • jinfo: System properties and VM CLI flags • jmap: Shared object memory map • jstack: Stack traces of Java threads • jstat: Performance statistics on class, JIT compiler, GC, ... • Advanced • jconsole / Visual VM • NewRelic, FiveRuns, ...
  • 47. jConsole http://blogs.sun.com/arungupta/tags/rubyonrails+jmx
  • 48. Turbo charging your JRuby Startup • “-client” or “-server” ? (Upto 50%) • Faster startup or solid runtime ? • export JAVA_OPTS=”-client -D32” • Upto 50% improvement • For Linux: Class Data Sharing • Delay or disable JRuby's JIT (Upto 10%) • -X-C • jruby.compile.mode=OFF • Avoid spawning “sub-Rubies” • Nailgun for small JRuby CLI invocations • Favorite JVM Flags
  • 49. Who loves Rails on GlassFish ?
  • 50. Resources • glassfish.org • blogs.sun.com/theaquarium • glassfish-scripting.dev.java.net • wiki.glassfish.java.net/Wiki.jsp? page=JRuby • blogs.sun.com/arungupta

×