Your SlideShare is downloading. ×
TorqueBox - moc Javy, piękno Rubiego
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

TorqueBox - moc Javy, piękno Rubiego

1,064
views

Published on

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
1,064
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
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. TorqueBox Moc Javy – piękno Rubiego
  • 2. Marek.
  • 3. JBoss AS 7 + =
  • 4. No, do rzeczy panie!
  • 5. Dziś w menu:
  • 6. 50 / 40 / 10
  • 7. Czym jestTorqueBox?
  • 8. Ruby i Java? Huh?
  • 9. DO RZECZY!
  • 10. Cel.
  • 11. Web: Rails, Sinatra, Rack.
  • 12. Ponadto: wiadomości,zadania, usługi, [...].
  • 13. Brzmiznajomo?
  • 14. Java już to ma,wykorzystajmy to!
  • 15. RandkowanieJBoss AS oraz Ruby.
  • 16. Ale dlaczego Ruby?
  • 17. Bob lubi Rubiego.
  • 18. Dynamiczny.
  • 19. Brak kompilacji.
  • 20. Liberalny.
  • 21. Zwięzły.
  • 22. Set<Person> people = new HashSet<Person>();for (Team each : teams) { people.addAll(each.getMembers());}for (Person each : people) { each.promote();} com/foo/Anything.java
  • 23. teams. collect(&:members). flatten.uniq.each &:promote! anything.rb
  • 24. Wporzo, ale co z wydajnością?
  • 25. JRuby FTW!
  • 26. Bardzo szybkie środowisko.
  • 27. Prawdziwe wątki.
  • 28. Biblioteki Javy, za free.
  • 29. TB 1.x – JBoss AS 6TB 2.x – JBoss AS 7
  • 30. Instalacja.
  • 31. $ wget http://torquebox.org/builds/LATEST/torquebox-dist-bin.zip$ unzip -q torquebox-dist-bin.zip$ export TORQUEBOX_HOME=$PWD/torquebox-1*$ export JBOSS_HOME=$TORQUEBOX_HOME/jboss$ export JRUBY_HOME=$TORQUEBOX_HOME/jruby$ export PATH=$JRUBY_HOME/bin:$PATH
  • 32. Zbytskomplikowane?
  • 33. $ gem install torquebox-server --pre --source http://torquebox.org/2x/builds/LATEST/gem-repo/$ torquebox run
  • 34. Tak, na Windowsie również.
  • 35. Zainstalowane, co dalej?
  • 36. Aplikacja webowa,powiedzmy Rails.
  • 37. $ rails new app -m $TORQUEBOX_HOME/share/rails/template.rb$ cd app$ rake torquebox:deploy[‘/app’]http://localhost:8080/app/
  • 38. To może jakiś kod co działa?
  • 39. $ rails g scaffold Coffee name:string description:text$ rake db:migratehttp://localhost:8080/app/coffees/
  • 40. Demo!
  • 41. Nie takie rzeczy widziałem!
  • 42. Integracja z Javą.
  • 43. Rubyclass SomeController def index session[:password] = sw0rdfish endend
  • 44. Javapublic class SomeServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) { request.getSession().getValue("password"); }}
  • 45. Klastrowanie?
  • 46. Sklastruj JBoss’a!
  • 47. mod_cluster
  • 48. Dynamicznakonfiguracja!
  • 49. Koniec oaplikacjachwebowych.
  • 50. Zaplanowane zadania.
  • 51. class NewsletterSender def run subscriptions = Subscription.find(:all) subscriptions.each do |e| send_newsletter(e) end endend app/jobs/newsletter_sender.rb
  • 52. jobs: monthly_newsletter: description: first of month job: NewsletterSender cron: ‘0 0 0 1 * ?’ config/torquebox.yml
  • 53. Messaging.
  • 54. Zadania w tle.
  • 55. class Something def foo end def bar endend
  • 56. something = Something.newsomething.foosomething.bar
  • 57. class Something include TorqueBox::Messaging::Backgroundable def foo end def bar endend
  • 58. something = Something.newsomething.background.foosomething.bar
  • 59. class Something include TorqueBox::Messaging::Backgroundable always_background :foo def foo end def bar endend
  • 60. something = Something.newsomething.foosomething.bar
  • 61. Kolejki.
  • 62. queues: /queues/questions /queues/answerstopics: /topics/new_accounts /topics/notifications config/torquebox.yml
  • 63. messaging: /topics/print: PrintHandler: color: ‘red’ /queues/popular: AdultObserver: filter: "age >= 18" concurrency: 5 config/torquebox.yml
  • 64. include TorqueBoxqueue = Messaging::Queue.new /queues/fooqueue.create...queue.destroy
  • 65. include TorqueBox::Messagingclass PrintHandler < MessageProcessor def initialize(opts) @color = opts[color] end def on_message(body) puts “#{body} in #{@color}” endend config/torquebox.yml
  • 66. Usługi.
  • 67. Nie-webowe, długie demony.
  • 68. class MyService def initialize(opts={}) @queue = Messaging::Queue.new(opts[:queue]) end def start Thread.new { run } end def stop @done = true end def run until @done @queue.publish(Time.now) sleep(1) end endend app/processors/my_service.rb
  • 69. Cacheowanie.
  • 70. Wstrzykiwanie.
  • 71. package com.mycorp;@ApplicationScopedclass Something { @Inject private Else else; public void print(String what) { # blah }}@ApplicationScopedclass Else {}
  • 72. class MyService include TorqueBox::Injectors def initialize(opts={}) @thing = inject(Java::com.mycorp.Something) @thing.print(‘Marek’) endend
  • 73. CDI to tylkoprzykład: kolejki,tematy, heroina, inne rzeczy.
  • 74. Drugs are bad, m’kay?
  • 75. inject_topic( "/topics/questions" )inject_queue( "/queues/answers" )inject_namig( "java:comp/env/jdbc/myDS )
  • 76. Demo!
  • 77. FirefoxTwitter Twitter Service TorqueBox Konsument JBoss AS 7 Zadania Rails kolejki TorqueBox Kolejka JMS CDI JPA 2.0 JBoss AS 7 Baza danych
  • 78. OK, fajnie, ale jak to jest wydajne?
  • 79. http://torquebox.org/http://github.com/torqueboxhttp://github.com/goldmann/confitura-2011-torquebox-demoIRC: #torquebox on FreeNode@torquebox
  • 80. Dzięki.Nie zapomnij o naklejkach!