0
-JRuby-Rack is a lightweight adapter for the Java servlet environment that allows
0
-any Rack-based application to run unmodified in a Java servlet container.
0
-JRuby-Rack supports Rails, Merb, as well as any Rack-compatible Ruby web
0
+JRuby-Rack is a lightweight adapter for the Java servlet environment
0
+that allows any Rack-based application to run unmodified in a Java
0
+servlet container. JRuby-Rack supports Rails, Merb, as well as any
0
+Rack-compatible Ruby web framework.
0
For more information on Rack, visit http://rack.rubyforge.org.
0
@@ -9,46 +9,56 @@ For more information on Rack, visit http://rack.rubyforge.org.
0
-JRuby-Rack's main mode of operation is as a servlet filter. This allows requests
0
-for static content to pass through and be served by the application server.
0
-Dynamic requests only happen for URLs that don't have a corresponding file, much
0
-like many Ruby applications expect.
0
+JRuby-Rack's main mode of operation is as a servlet filter. This
0
+allows requests for static content to pass through and be served by
0
+the application server. Dynamic requests only happen for URLs that
0
+don't have a corresponding file, much like many Ruby applications
0
== Goldspike-compatible Servlet
0
-JRuby-Rack includes a stub RailsServlet and recognizes many of Goldspike's
0
-context parameters (e.g., pool size configuration), making it interchangeable
0
-with Goldspike, for convenience of migration. One caveat is that static content
0
-is served by Rack, which requires acquisition of a JRuby runtime. Your
0
-throughput with static files will be much lower than when JRuby-Rack is
0
-configured as a servlet filter. You have been warned!
0
+JRuby-Rack includes a stub RailsServlet and recognizes many of
0
+Goldspike's context parameters (e.g., pool size configuration), making
0
+it interchangeable with Goldspike, for convenience of migration. One
0
+caveat is that static content is served by Rack, which requires
0
+acquisition of a JRuby runtime. Your throughput with static files will
0
+be much lower than when JRuby-Rack is configured as a servlet filter.
0
+==
Servlet environment integration0
-The Rails controller setting ActionController::Base.relative_url_root is set for
0
-you automatically according to the context root where your webapp is deployed.
0
+- Servlet context is accessible to any application both through the
0
+ global variable $servlet_context and the Rack environment variable
0
+- Servlet request object is available in the Rack environment via the
0
+ key java.servlet_request.
0
+- Servlet request attributes are passed through to the Rack
0
+- Rack environment variables and headers can be overridden by servlet
0
+- Java servlet sessions are used as the default session store for both
0
+ Rails and Merb. Session attributes with String keys and String,
0
+ numeric, boolean, or java object values are automatically copied to
0
+ the servlet session for you.
0
-
== Servlet environment integration0
+
Several aspects of Rails are automatically set up for you.0
-- Servlet context is accessible to any application both through the global
0
- variable $servlet_context, the pre-defined constant
0
- JRuby::Rack::ServletContext, and the Rack environment variable
0
-- Servlet request object is available in the Rack environment via the key
0
-- Servlet request attributes are passed through to the Rack environment.
0
-- Rack environment variables and headers can be overridden by servlet request
0
-- Java servlet sessions are used as the default session store for both Rails and
0
+- The Rails controller setting ActionController::Base.relative_url_root
0
+ is set for you automatically according to the context root where
0
+ your webapp is deployed.
0
+- Rails logging output is redirected to the application server log.
0
+- Page caching and asset directories are configured appropriately.
0
== JRuby Runtime Management
0
-JRuby runtime management and pooling is done automatically by the framework. In
0
-the case of Rails, runtimes are pooled. For Merb and other Rack applications, a
0
-single runtime is created and shared for every request.
0
+JRuby runtime management and pooling is done automatically by the
0
+framework. In the case of Rails, runtimes are pooled. For Merb and
0
+other Rack applications, a single runtime is created and shared for
0
@@ -69,11 +79,14 @@ The generated jar should be located here: target/jruby-rack-*.jar.
0
-This example shows how to create and deploy a simple Rails app using the
0
-embedded Java database H2 to a WAR using Warble and JRuby Rack. JRuby Rack is now
0
-included in the latest release of Warbler (0.9.9), but you can build your own jar from source and substitute it if you like.
0
+This example shows how to create and deploy a simple Rails app using
0
+the embedded Java database H2 to a WAR using Warble and JRuby Rack.
0
+JRuby Rack is now included in the latest release of Warbler (0.9.9),
0
+but you can build your own jar from source and substitute it if you
0
-Install Rails and the driver and ActiveRecord adapters for the H2 database:
0
+Install Rails and the driver and ActiveRecord adapters for the H2
0
jruby -S gem install rails activerecord-jdbch2-adapter
0
@@ -108,8 +121,8 @@ Run the database migration that was just created as part of the scaffold.
0
jruby -S rake db:migrate
0
-Start your application on the Rails default port 3000 using Mongrel/ and make
0
+Start your application on the Rails default port 3000 using Mongrel/
0
+and make sure it works:
0
@@ -117,22 +130,23 @@ Generate a custom Warbler WAR configuration for the blog application
0
-Generate a production version of the H2 database for the blog application:
0
+Generate a production version of the H2 database for the blog
0
RAILS_ENV=production jruby -S rake db:migrate
0
-Edit this file: config/warble.rb and add the following line after these
0
+Edit this file: config/warble.rb and add the following line after
0
# Additional files/directories to include, above those in config.dirs
0
# config.includes = FileList["db"]
0
config.includes = FileList["db/production_h2*"]
0
-This will tell Warble to include the just initialized production H2 database in
0
+This will tell Warble to include the just initialized production H2
0
-Continue editing config/warble.rb and add the following line after these
0
+Continue editing config/warble.rb and add the following line after
0
# Gems to be packaged in the webapp. Note that Rails gems are added to this
0
# list if vendor/rails is not present, so be sure to include rails if you
0
@@ -142,22 +156,25 @@ comments:
0
# config.gems["rails"] = "1.2.3"
0
config.gems << "activerecord-jdbch2-adapter"
0
-This will tell Warble to add the JDBC driver for H2 as well as the ActiveRecord
0
-JDBC and JDBC-H2 adapter Gems.
0
+This will tell Warble to add the JDBC driver for H2 as well as the
0
+ActiveRecord JDBC and JDBC-H2 adapter Gems.
0
Now generate the WAR file:
0
-This task generates the file: blog.war at the top level of the application as
0
-well as an exploded version of the war located here: tmp/war.
0
+This task generates the file: blog.war at the top level of the
0
+application as well as an exploded version of the war located here:
0
The war should be ready to deploy to your Java application server.
0
- Dudley Flanders, for the Merb support
0
-- Robert Egglestone, for the original JRuby servlet integration project, Goldspike
0
+- Robert Egglestone, for the original JRuby servlet integration
0
- Chris Neukirchen, for Rack
0
- Sun Microsystems, Nick's employer, for project support
0
-- Last, but not least, Flannery, Nick's wife, for patience and understanding
0
+- Last, but not least, Flannery, Nick's wife, for patience and
Comments
No one has commented yet.