public
Description: Rack for JRuby and Java appservers
Homepage: http://wiki.jruby.org/wiki/JRuby_Rack
Clone URL: git://github.com/nicksieger/jruby-rack.git
Updated README with a few extras from the wiki


git-svn-id: https://svn.codehaus.org/jruby-contrib/trunk/rack@163 
97a6c6ee-731e-0410-87e5-e5612b5efbfe
nsieger (author)
Fri May 16 20:56:32 -0700 2008
commit  9898df2471e0ebf1a381269a1db73456618b6a59
tree    8d57a583a76e39264c49482e7a09109c8ffca41b
parent  a0aaad2779ab674ccf4a26f44756e7b183335225
...
1
2
3
4
 
 
 
 
5
6
7
...
9
10
11
12
13
14
15
 
 
 
 
 
16
17
18
19
20
21
22
23
24
 
 
 
 
 
 
 
25
26
 
27
28
29
 
 
 
 
 
 
 
 
 
 
 
 
 
30
31
 
32
33
 
34
35
36
37
38
39
40
41
42
43
44
45
 
 
 
 
 
 
 
46
47
48
49
50
51
 
 
 
 
52
53
54
...
69
70
71
72
73
74
 
 
 
 
 
75
76
 
 
77
78
79
...
108
109
110
111
112
 
 
113
114
115
...
117
118
119
120
 
 
121
122
123
124
125
 
 
126
127
128
129
130
131
132
 
 
133
134
135
 
 
136
137
138
...
142
143
144
145
146
 
 
147
148
149
150
151
152
153
 
 
 
154
155
156
157
158
159
160
 
 
161
162
163
 
 
...
 
 
 
 
1
2
3
4
5
6
7
...
9
10
11
 
 
 
 
12
13
14
15
16
17
18
19
 
 
 
 
 
 
20
21
22
23
24
25
26
27
 
28
29
 
 
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 
44
45
 
46
47
 
 
 
 
 
 
 
 
 
 
 
48
49
50
51
52
53
54
55
56
57
 
 
 
58
59
60
61
62
63
64
...
79
80
81
 
 
 
82
83
84
85
86
87
 
88
89
90
91
92
...
121
122
123
 
 
124
125
126
127
128
...
130
131
132
 
133
134
135
136
137
 
 
138
139
140
141
142
143
144
 
 
145
146
147
 
 
148
149
150
151
152
...
156
157
158
 
 
159
160
161
162
163
164
165
 
 
166
167
168
169
170
171
172
173
174
 
175
176
177
178
 
179
180
0
@@ -1,7 +1,7 @@
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
-framework.
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
 
0
 For more information on Rack, visit http://rack.rubyforge.org.
0
 
0
@@ -9,46 +9,56 @@ For more information on Rack, visit http://rack.rubyforge.org.
0
 
0
 == Servlet Filter
0
 
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
+expect.
0
 
0
 == Goldspike-compatible Servlet
0
 
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
+You have been warned!
0
 
0
-== Rails
0
+== Servlet environment integration
0
 
0
-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
+ java.servlet_context.
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
+ environment.
0
+- Rack environment variables and headers can be overridden by servlet
0
+ request attributes.
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
 
0
-== Merb
0
+== Rails
0
 
0
-== Servlet environment integration
0
+Several aspects of Rails are automatically set up for you.
0
 
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
- java.servlet_context.
0
-- Servlet request object is available in the Rack environment via the key
0
- java.servlet_request.
0
-- Servlet request attributes are passed through to the Rack environment.
0
-- Rack environment variables and headers can be overridden by servlet request
0
- attributes.
0
-- Java servlet sessions are used as the default session store for both Rails and
0
- Merb.
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
+
0
+== Merb
0
 
0
 == JRuby Runtime Management
0
 
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
+every request.
0
 
0
 = Building
0
 
0
@@ -69,11 +79,14 @@ The generated jar should be located here: target/jruby-rack-*.jar.
0
 
0
 == Rails Step-by-step
0
 
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
+like.
0
 
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
+database:
0
 
0
   jruby -S gem install rails activerecord-jdbch2-adapter
0
 
0
@@ -108,8 +121,8 @@ Run the database migration that was just created as part of the scaffold.
0
 
0
   jruby -S rake db:migrate
0
 
0
-Start your application on the Rails default port 3000 using Mongrel/ and make
0
-sure it works:
0
+Start your application on the Rails default port 3000 using Mongrel/
0
+and make sure it works:
0
 
0
   jruby script/server
0
 
0
@@ -117,22 +130,23 @@ Generate a custom Warbler WAR configuration for the blog application
0
 
0
   jruby -S warble config
0
 
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
+application:
0
 
0
   RAILS_ENV=production jruby -S rake db:migrate
0
 
0
-Edit this file: config/warble.rb and add the following line after these
0
-comments:
0
+Edit this file: config/warble.rb and add the following line after
0
+these comments:
0
 
0
   # Additional files/directories to include, above those in config.dirs
0
   # config.includes = FileList["db"]
0
   config.includes = FileList["db/production_h2*"]
0
 
0
-This will tell Warble to include the just initialized production H2 database in
0
-the WAR.
0
+This will tell Warble to include the just initialized production H2
0
+database in the WAR.
0
 
0
-Continue editing config/warble.rb and add the following line after these
0
-comments:
0
+Continue editing config/warble.rb and add the following line after
0
+these comments:
0
 
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
 
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
 
0
 Now generate the WAR file:
0
 
0
   jruby -S warble war
0
 
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
+tmp/war.
0
 
0
 The war should be ready to deploy to your Java application server.
0
 
0
 = Thanks
0
 
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
+ project, Goldspike
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
0
+ understanding

Comments

    No one has commented yet.