This section gives you an overview of JRuby and Rails on the Sun GlassFish by explaining the following concepts:
What is Ruby on Rails?
What is JRuby?
The Sun GlassFish Enterprise Server v3 Prelude and the GlassFish v3 Gem
Ruby is an interpreted, dynamically-typed, object-oriented programming language. It has a simple, natural syntax that enables developers to create applications quickly and easily. It also includes the easy-to-use RubyGems packaging utility for customizing a Ruby installation with additional plug-ins.
Rails is a web application framework that leverages the simplicity of Ruby and eliminates much of the repetition and configuration required in other programming environments. With Rails, you can create a database-backed web application, complete with models and tables, by running a few one-line commands.
To learn more about Ruby on Rails, see Ruby on Rails.
JRuby is a JavaTM implementation of the Ruby interpreter. While retaining many of the popular characteristics of Ruby, such as dynamic-typing, JRuby is integrated with the Java platform. With JRuby on Rails, you get the simplicity and productivity offered by Ruby and Rails and the power of the Java platform offered by JRuby, thereby giving you many benefits as a Rails developer, including these:
You can access the rich set of Java libraries from your Rails application.
You can use the powerful and secure support of Java Unicode strings with your Rails application.
Your JRuby on Rails application can spin off multiple threads because JRuby uses Java threads, which map to native Ruby threads. Furthermore, you can pool these threads.
To learn more about JRuby, see JRuby.
Developing and deploying your Rails application on the Sun GlassFish Enterprise Server gives you the following advantages over using a typical web server used for running Rails applications:
A simple, integrated deployment environment. In other words, you do not need one set of software for developing the application and another set of software for deploying it.
The ability to deploy multiple Rails applications to a single GlassFish instance.
The ability of a Rails application to handle multiple requests.
For more details on these and other advantages of using the GlassFish for your JRuby on Rails applications, see Advantages of JRuby-on-Rails with the GlassFish Application Server.
You have two options for deploying a Rails application on the Sun GlassFish:
Deploy the application as a directory to the Sun GlassFish Enterprise Server v3 Prelude by using the asadmin command.
Deploy the application as a directory to the GlassFish v3 Gem installed on your JRuby virtual machine.
A Gem is a Ruby package that contains a library or an application. In fact, Rails itself is a Gem that you install on top of JRuby.
One way to work with JRuby on Sun GlassFish is to install the GlassFish v3 Gem on top of your JRuby installation. The GlassFish v3 Gem is just a lightweight version of the Sun GlassFish Enterprise Server v3 Prelude and a Grizzly connector for JRuby.
When you install the Gem, you have a Sun GlassFish instance embedded in the JRuby virtual machine. This gives you a more complete development and production environment because you have everything you need for JRuby on Rails applications running inside the JRuby virtual machine in addition to everything you need from the Sun GlassFish to create web applications.