Exit Print View

Sun GlassFish Enterprise Server v3 Scripting Framework Guide

  This Document Entire Library
Print View

Document Information

Preface

1.  Using JRuby on Rails With Sun GlassFish Enterprise Server

Introduction to JRuby and Rails on Sun GlassFish Enterprise Server

What Is Ruby on Rails ?

What Is JRuby ?

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

To Install Rails Gem on JRuby

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

GlassFish v3 Gem

To Install the GlassFish v3 Gem

To Run a Rails Application on GlassFish v3 Gem

To Deploy and Run the Database-Backed Web Application

Using GlassFish v3 Gem CLI

Introduction to Warbler

What Is Warbler ?

Creating and Deploying a Simple Rails Application with Warbler

To Create a Rails Application

To Deploy the WAR File

Further Information

2.  Developing Grails Applications

3.  Jython on Django

4.  Scala and Lift

5.  PHP

Enterprise Server v3 JRuby Container Configuration

The Sun GlassFish Enterprise Server v3 provides the following ways to configure the installed JRuby container.

Configuring JRuby Container Through Asadmin CLI

The asadmin CLI now provides options to configure the JRuby container. The command execution is reflected in changes to the JRuby container configuration section of the domain.xml file which makes them persistent.

The following JRuby container properties can be configured through the asdmin command.

configure-jruby-container [--help]
     [--monitoring={false|true}]
     [--jruby-home jruby-home]
     [--jruby-runtime jruby-runtime]
     [--jruby-runtime-min jruby-runtime-min]
     [--jruby-runtime-max jruby-runtime-max]
     [--show={true|false}]

Use the following asadmin command syntax to configure these values:

asadmin configure-jruby-container --<property>=<value>

For example, the following command is used to set the JRuby home if JRuby instance is installed as standalone:

asadmin configure-jruby-container --jruby.home=/<jruby-install-location>

You can also change the deployment specific options to the JRuby application through the following command syntax:

asadmin deploy --property <name>=<value>[:<name>=<value>]

For example, the following command uses a JRuby instance to deploy your application which is different from the one configured with the Enterprise Server:

asadmin deploy --property jruby.home=/<latest-jruby-install> <application>

For a detailed description of these options, see configure-jruby-container(1).

The JRuby container runtime pool options are discussed in the next section.

Configuring JRuby Runtime Pool

The Sun GlassFish Enterprise Server v3 provides a JRuby runtime pool to allow servicing of multiple concurrent requests. However Rails is not currently thread-safe, and while JRuby is able to take advantage of Java's native threading, Rails cannot benefit from it. Each JRuby runtime runs a single instance of Rails, and requests are handed off to whichever instance happens to be available at the time of the request.

The JRuby properties in the above configuration are explained as follows:

The dynamic runtime pool maintains itself with the minimum number of runtimes possible, to allow consistent and fast runtime access for the requesting application. The pool may take a initial runtime value, but that value is not used after pool creation.

The JRuby runtime pool values can be set either at container level or at deploy time. To set the runtime pool values at container level, use the following asadmin command:

asadmin configure-jruby-container --jruby-runtime=2 --jruby-runtime-min=1 --jruby-runtime-max=3

Note that each of the above properties can be set separately at a time. To set the runtime pool values at deploy time use the following asadmin command:

asadmin deploy --property jruby-runtime=2:jruby-runtime-min=1:jruby-runtime-max=3

Each of the above properties also can be set at a time or at the same time. If both settings are used, deploy time settings take precedence over container runtime settings.

Configuring JRuby Container Through Administration Console

The JRuby container values can be set from Enterprise Server Administration Console. For details on Administration Console, see Administration Console in Sun GlassFish Enterprise Server v3 Administration Guide.

You can set the following container properties from the Administration Console:

Use the following steps to access JRuby Container from Administration Console.

To Configure JRuby Container from Administration Console

  1. Access the Enterprise Server Administration Console from web browser. For example:

    http://localhost:4848
  2. Login to the Administration Consoleif configured for secure login.

  3. Select Common Tasks->Configuration->JRuby Container on the left-hand tree panel.

  4. Change JRuby Container values from the details panel.