SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 357 | Next

Ola Bini

"Practical JRuby on Rails Web 2.0 Projects: Bringing Ruby on Rails to Java"

new(id.to_i, name,
authors, isbn, instances)
end
all
end
Finally, if you want to test this Ruby code, you can use this test code at the end of the file:
if __FILE__ == $0
id = LegacySystem.add_library("FooLib")
id2 = LegacySystem.add_library("BarLib")
LegacySystem.remove_library(id)
bid = LegacySystem.add_book_description(
BookDescription.new(nil, "Practical Stuff",
["Ola Bini", "Arnold Donner"], "123443545"))
LegacySystem.add_book_instance(id2, bid)
mid = LegacySystem.add_book_instance(id2, bid)
LegacySystem.add_book_instance(id2, bid)
LegacySystem.lend_book_instance(mid)
require 'pp'
pp LegacySystem.search("%","%")
end
It creates two new libraries, removes one, adds a book description and some instances,
lends an instance, and then searches and pretty prints the result. From this, you see how to
work with the library. To invoke the script, create a script called jrun, which looks exactly like
the run script created earlier, but replace the word java with jruby in it. Then you can try the
application out. Remember that you need to kill the process explicitly with Ctrl+C.
That??™s the grand total of integration with the legacy library. As you can see, it isn??™t too
painful to hide a binary protocol behind a nice Ruby API. You??™ll be able to use this library
directly from your Rails application in the next chapter to provide library services for the
LibLib application.
CHAPTER 13 ?–  JRUBY AND MESSAGE-ORIENTED SYSTEMS 247
Inter-Rails Communication
You??™ve now seen one approach to using JMS for communication through Ruby.


Pages:
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369