torquebox oscon java 2011

Download Torquebox OSCON Java 2011

If you can't read please download the document

Post on 22-Apr-2015

3.177 views

Category:

Technology

3 download

Embed Size (px)

DESCRIPTION

 

TRANSCRIPT

  • 1. The Beauty of Ruby with the Power of Java Toby Crawley OSCON JavaCreative Commons BY-SA 3.0 July 2011
  • 2. Toby Crawley! @tcrawley TorqueBox Core Developer Red Hat Senior Engineer
  • 3. but its a team.
  • 4. What is TorqueBox? The mating of JRuby to JBoss AS.
  • 5. Application Server? Sinatra Rails Rack Passenger/Thin Apache/Nginx
  • 6. Application Server? Sinatra Rails Rack Tasks Passenger/Thin Resque/ DelayedJob Apache/Nginx
  • 7. Application Server? Sinatra Rails Rack Tasks Passenger/Thin Jobs Resque/ DelayedJob Apache/Nginx crond
  • 8. Application Server? Sinatra Rails Rack Tasks Passenger/Thin Jobs Resque/ DelayedJob Apache/Nginx crond Daemons god/monit
  • 9. TorqueBox ASSinatra Rails Rack Tasks Procs Jobs Daemons Web Messaging Scheduling Services JBoss AS Clustering Load Balancing HA
  • 10. Goals Support Ruby web frameworks Rails Sinatra Rack
  • 11. Goals Support Ruby web frameworks Rails Sinatra Rack Go beyond the web Messaging Jobs Services
  • 12. Goals No XML, No Java(unless youre into that sort of thing)
  • 13. Why Ruby? No compilation Highly expressive Lots of shiny frameworks Few specifications (more fun!) Meta-programming
  • 14. Expressivecom/foo/Anything.javaSet people = new HashSet();for ( Team each : teams ) { people.addAll( each.getMembers() );}for ( Person each : people ) { each.promote();}
  • 15. Expressiveanything.rbteams.collect(&:members). flatten.uniq.each(&:promote)
  • 16. Expressiveanything.rball_members = teams.collect(&:members)all_members.flatten!.uniq!all_members.each(&:promote)
  • 17. Why JRuby?
  • 18. Why JRuby?system = Java::java.lang.Systemsystem.properties.each do |k,v| system.properties[k] = v.upcaseend
  • 19. Why JRuby? Very fast runtime Real threads Java libraries Java tools Healthy community
  • 20. TorqueBox Details Builds upon and requires JBoss AS 6.x. Tight integration with the JBoss stack.
  • 21. Easy Install(download 1.1 from torquebox.org)$ unzip torquebox-dist-1.1-bin.zip$ export TORQUEBOX_HOME=$PWD/torquebox-1.1$ export JBOSS_HOME=$TORQUEBOX_HOME/jboss$ export JRUBY_HOME=$TORQUEBOX_HOME/jruby$ export PATH=$JRUBY_HOME/bin:$PATH
  • 22. Easy Install(download 1.1 from torquebox.org)$ unzip torquebox-dist-1.0.0-bin.zip$ export TORQUEBOX_HOME=$PWD/torquebox-1.1$ export JBOSS_HOME=$TORQUEBOX_HOME/jboss$ export JRUBY_HOME=$TORQUEBOX_HOME/jruby$ export PATH=$JRUBY_HOME/bin:$PATH
  • 23. Easy Install(download 1.1 from torquebox.org)$ unzip torquebox-dist-1.1-bin.zip$ export TORQUEBOX_HOME=$PWD/torquebox-1.1$ export JBOSS_HOME=$TORQUEBOX_HOME/jboss$ export JRUBY_HOME=$TORQUEBOX_HOME/jruby$ export PATH=$JRUBY_HOME/bin:$PATH
  • 24. Easy Install(download 1.1 from torquebox.org)$ unzip torquebox-dist-1.1-bin.zip$ export TORQUEBOX_HOME=$PWD/torquebox-1.1$ export JBOSS_HOME=$TORQUEBOX_HOME/jboss$ export JRUBY_HOME=$TORQUEBOX_HOME/jruby$ export PATH=$JRUBY_HOME/bin:$PATH
  • 25. Easy Install(download 1.1 from torquebox.org)$ unzip torquebox-dist-1.0.0.CR1-bin.zip Make sure the jruby found in your path is in $ export TORQUEBOX_HOME=$PWD/torquebox-1* $JRUBY_HOME/bin.$ export JBOSS_HOME=$TORQUEBOX_HOME/jboss$ export JRUBY_HOME=$TORQUEBOX_HOME/jruby$ export PATH=$JRUBY_HOME/bin:$PATH
  • 26. Easy Install(download 1.1 from torquebox.org)$ unzip torquebox-dist-1.0.0.CR1-bin.zip Make sure the jruby found in your path is in $ export TORQUEBOX_HOME=$PWD/torquebox-1* $JRUBY_HOME/bin.$ export JBOSS_HOME=$TORQUEBOX_HOME/jboss$ export JRUBY_HOME=$TORQUEBOX_HOME/jruby$ export PATH=$JRUBY_HOME/bin:$PATH
  • 27. Deploymentrake torquebox:run Run TorqueBox serverrake torquebox:deploy[context_path] Deploy the app in the current directoryrake torquebox:undeploy Undeploy the app in the current directory
  • 28. DeploymentThe torquebox:deploy task creates:$TORQUEBOX_HOME/apps/my-app.yml
  • 29. WebRun Ruby web-apps within the context of the Servlet container. Without compilation.
  • 30. But continue editing Continue live-editing of running app: models,views, controllers...
  • 31. Non-surprising. Almost boring.
  • 32. Web (Session Integration)class SomeController def index session[:password] = sw0rdfish endend
  • 33. Web (Session Integration)public class SomeServlet { public void doGet(HttpServletRequest request, HttpServletResponse resp) { request.getSession().getValue("password"); }}
  • 34. ClusteringRuby applications participate fully in AS clustering.Can use JBoss mod_cluster.