1. Using JRuby on Rails With Sun GlassFish Enterprise Server
Introduction to JRuby and Rails on Sun GlassFish Enterprise Server
JRuby on Rails, the Sun GlassFish Enterprise Server v3, and the GlassFish v3 Gem
Installation and Configuration of JRuby
To Install JRuby and Rails from Update Center
To Install JRuby as Standalone
Enterprise Server v3 JRuby Container Configuration
Configuring JRuby Container Through Asadmin CLI
Configuring JRuby Runtime Pool
Configuring JRuby Container Through Administration Console
To Configure JRuby Container from Administration Console
Creating a Simple Rails Application
To Create the hello Application
To Create the Controller and the View
To Pass Data From the Controller to the View
To Use Rails Without a Database
Deploying and Running a Rails Application
To Deploy the Rails Application as a Directory
Accessing a Database From a Rails Application
To Set Up the MySQL Database Server
To Create a Database-Backed Rails Application
Accessing Java Libraries From a Rails Application
To Create the Rails Application That Accesses Java Libraries
To Create the Views That Display the Images Generated by Java2D Code
To Add Java2D Code to a Rails Controller
To Run a Rails Application That Uses Java 2D Code
Monitor Rails Applications on Enterprise Server v3
Monitoring for JRuby Container
Viewing JRuby Container Statistics
To Install the GlassFish v3 Gem
To Run a Rails Application on GlassFish v3 Gem
To Deploy and Run the Database-Backed Web Application
Creating and Deploying a Simple Rails Application with Warbler
This section gives you an overview of JRuby and Rails on the Sun GlassFish Enterprise Server by explaining the following concepts:
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 database-backed web applications, 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 Java 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 the following:
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 Server instance.
The ability of a Rails application to handle multiple requests.
You have the following options for deploying a Rails application on GlassFish Server:
Deploy the application as a directory to the Enterprise Server v3.
Run the application using GlassFish v3 Gem.
A Gem is a Ruby package that contains a library or an
application. In fact, Rails itself is a Gem that is installed on JRuby.
For more details on GlassFish v3 Gem, see GlassFish v3 Gem.