jruby-rack 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,7 +1,21 @@
1
+ == 1.1.5 (04/03/12)
2
+
3
+ - bundler 1.1 workaround when ENV is cleared - set ENV['PATH'] = ''
4
+ - resolve servlet context from request.getServletContext if posssible
5
+ - resetUnhandledResponse init param for controlling chain response handling
6
+ - filter specific context params deprecated in favor of filter init params
7
+ - logging should not depend on $servlet_context global (better #88 fix)
8
+ - cleanup request buffer /tmp files after input stream gets closed
9
+ - add an embed Config to correctly setup RackConfig from ruby runtime
10
+ - introduce RackConfig#getOut/getErr for possible 1/2 stream redirection
11
+ - ensure ENV changes do not affect the native environment (#101)
12
+ - change Rails.public_path early on (#99) and do not set PUBLIC_ROOT in 3.x
13
+ - synchronize session operations with JavaServletStore (#95)
14
+ - allow configuring request buffer initial/maximum size using parameters
15
+ - initialization exception behavior in listener might be overriden (#16)
16
+
1
17
  == 1.1.4 (02/21/12)
2
18
 
3
- - Thanks to @kares for all the maintenance and quick turnaround on
4
- bugs this release!
5
19
  - incorrectly interpreted byte in RewindableInputStream causing EOFs (#92)
6
20
  - fix JRuby::Rack::Response 1.9 incompatibility due String#each
7
21
  - ensure $servlet_context is not nil in embedded scenario (#88)
data/README.md CHANGED
@@ -1,46 +1,44 @@
1
1
  # JRuby-Rack
2
2
 
3
- JRuby-Rack is a lightweight adapter for the Java servlet environment
4
- that allows any Rack-based application to run unmodified in a Java
5
- servlet container. JRuby-Rack supports Rails, Merb, as well as any
6
- Rack-compatible Ruby web framework.
3
+ JRuby-Rack is a lightweight adapter for the Java servlet environment that allows
4
+ any Rack-based application to run unmodified in a Java servlet container.
5
+ JRuby-Rack supports Rails as well as any Rack-compatible Ruby web framework.
7
6
 
8
7
  For more information on Rack, visit http://rack.rubyforge.org.
9
8
 
9
+ [![Build Status](https://secure.travis-ci.org/jruby/jruby-rack.png?branch=master)](http://travis-ci.org/jruby/jruby-rack)
10
+
10
11
  # Getting Started
11
12
 
12
- The easiest way to use JRuby-Rack is to get [Warbler][1]. Warbler
13
- depends on the latest version of JRuby-Rack and ensures it gets placed in
14
- your WAR file when it gets built.
13
+ The easiest way to use JRuby-Rack is to get [Warbler][1].
14
+ Warbler depends on the latest version of JRuby-Rack and ensures it gets placed
15
+ in your WAR file when it gets built.
15
16
 
16
17
  If you're assembling your own WAR using other means, you can install the
17
- `jruby-rack` gem. It provides a method to locate the jruby-rack jar file:
18
+ **jruby-rack** gem. It provides a method to locate the jar file:
18
19
 
19
20
  require 'fileutils'
20
21
  require 'jruby-rack'
21
22
  FileUtils.cp JRubyJars.jruby_rack_jar_path, '.'
22
23
 
23
- Otherwise you'll need to download the [latest JRuby-Rack jar][2], drop
24
- it into the WEB-INF/lib directory and configure the RackFilter in your
25
- application's web.xml. Example web.xml snippets are as follows.
24
+ Otherwise you'll need to download the [latest jar release][2], drop it into the
25
+ *WEB-INF/lib* directory and configure the RackFilter in your application's
26
+ *web.xml*. Example web.xml snippets are as follows.
26
27
 
27
28
  ## For Rails
28
29
 
29
- Here's sample web.xml configuration for Rails. Note the environment
30
- and min/max runtime parameters. For multi-threaded Rails with a single
31
- runtime, set min/max both to 1. Otherwise, define the size of the
32
- runtime pool as you wish.
30
+ Here's sample web.xml configuration for Rails. Note the environment and min/max
31
+ runtime parameters. For multi-threaded Rails with a single runtime, set min/max
32
+ both to 1. Otherwise, define the size of the runtime pool as you wish.
33
33
 
34
34
  <context-param>
35
35
  <param-name>rails.env</param-name>
36
36
  <param-value>production</param-value>
37
37
  </context-param>
38
-
39
38
  <context-param>
40
39
  <param-name>jruby.min.runtimes</param-name>
41
40
  <param-value>1</param-value>
42
41
  </context-param>
43
-
44
42
  <context-param>
45
43
  <param-name>jruby.max.runtimes</param-name>
46
44
  <param-value>1</param-value>
@@ -49,6 +47,19 @@ runtime pool as you wish.
49
47
  <filter>
50
48
  <filter-name>RackFilter</filter-name>
51
49
  <filter-class>org.jruby.rack.RackFilter</filter-class>
50
+ <!-- optional filter configuration init-params : -->
51
+ <init-param>
52
+ <param-name>resetUnhandledResponse</param-name>
53
+ <param-value>true</param-value> <!-- true (default), false or buffer -->
54
+ </init-param>
55
+ <init-param>
56
+ <param-name>addsHtmlToPathInfo</param-name>
57
+ <param-value>true</param-value> <!-- true (default), false -->
58
+ </init-param>
59
+ <init-param>
60
+ <param-name>verifiesHtmlResource</param-name>
61
+ <param-value>false</param-value> <!-- true, false (default) -->
62
+ </init-param>
52
63
  </filter>
53
64
  <filter-mapping>
54
65
  <filter-name>RackFilter</filter-name>
@@ -61,9 +72,9 @@ runtime pool as you wish.
61
72
 
62
73
  ## For Other Rack Applications
63
74
 
64
- Here's a sample web.xml configuration for a Rack application. The main
65
- difference is that JRuby-Rack looks for a "rackup" file named
66
- `config.ru` in `WEB-INF/config.ru` or `WEB-INF/*/config.ru`.
75
+ Here's a sample web.xml configuration for a Rack application. The main difference
76
+ is that JRuby-Rack looks for a "rackup" file named **config.ru** in
77
+ `WEB-INF/config.ru` or `WEB-INF/*/config.ru`.
67
78
 
68
79
  <filter>
69
80
  <filter-name>RackFilter</filter-name>
@@ -78,16 +89,17 @@ difference is that JRuby-Rack looks for a "rackup" file named
78
89
  <listener-class>org.jruby.rack.RackServletContextListener</listener-class>
79
90
  </listener>
80
91
 
81
- If you don't have a config.ru or don't want to include it in your web
82
- app, you can embed it in web.xml as follows (using Sinatra as an
83
- example). Be sure to escape angle-brackets for XML!
92
+ If you don't have a config.ru or don't want to include it in your web app, you
93
+ can embed it in web.xml as follows (using Sinatra as an example).
94
+
95
+ Be sure to escape angle-brackets for XML !
84
96
 
85
97
  <context-param>
86
98
  <param-name>rackup</param-name>
87
99
  <param-value>
88
100
  require 'rubygems'
89
- gem 'sinatra', '~&gt; 1.0'
90
- require './lib/demo'
101
+ gem 'sinatra', '~&gt; 1.3'
102
+ require './lib/app'
91
103
  set :run, false
92
104
  set :environment, :production
93
105
  run Sinatra::Application
@@ -99,124 +111,112 @@ example). Be sure to escape angle-brackets for XML!
99
111
 
100
112
  ## Servlet Filter
101
113
 
102
- JRuby-Rack's main mode of operation is as a servlet filter. This
103
- allows requests for static content to pass through and be served by
104
- the application server. Dynamic requests only happen for URLs that
105
- don't have a corresponding file, much like many Ruby applications
106
- expect. The application can also be configured to dispatch through a
107
- servlet instead of a filter if it suits your environment better.
114
+ JRuby-Rack's main mode of operation is as a servlet filter. This allows requests
115
+ for static content to pass through and be served by the application server.
116
+ Dynamic requests only happen for URLs that don't have a corresponding file, much
117
+ like many Ruby applications expect.
118
+ The application can also be configured to dispatch through a servlet instead of
119
+ a filter if it suits your environment better.
108
120
 
109
121
  ## Servlet environment integration
110
122
 
111
- - Servlet context is accessible to any application both through the
112
- global variable $servlet_context and the Rack environment variable
113
- java.servlet_context.
123
+ - Servlet context is accessible to any application through the Rack environment
124
+ variable *java.servlet_context* as well as the `$servlet_context` global.
114
125
  - Servlet request object is available in the Rack environment via the
115
- key java.servlet_request.
116
- - Servlet request attributes are passed through to the Rack
117
- environment.
126
+ key *java.servlet_request*.
127
+ - Servlet request attributes are passed through to the Rack environment.
118
128
  - Rack environment variables and headers can be overridden by servlet
119
129
  request attributes.
120
- - Java servlet sessions are available as a session store for both
121
- Rails and Merb. Session attributes with String keys and String,
122
- numeric, boolean, or java object values are automatically copied to
123
- the servlet session for you.
130
+ - Java servlet sessions are available as a session store for Rails.
131
+ Session attributes with String keys and String, numeric, boolean, or java
132
+ object values are automatically copied to the servlet session for you.
124
133
 
125
134
  ## Rails
126
135
 
127
136
  Several aspects of Rails are automatically set up for you.
128
137
 
129
- - The Rails controller setting ActionController::Base.relative_url_root
138
+ - The Rails controller setting `ActionController::Base.relative_url_root`
130
139
  is set for you automatically according to the context root where
131
140
  your webapp is deployed.
132
- - Rails logging output is redirected to the application server log.
141
+ - `Rails.logger` output is redirected to the application server log.
133
142
  - Page caching and asset directories are configured appropriately.
134
143
 
135
144
  ## JRuby Runtime Management
136
145
 
137
- JRuby runtime management and pooling is done automatically by the
138
- framework. In the case of Rails, runtimes are pooled. For Merb and
139
- other Rack applications, a single runtime is created and shared for
140
- every request.
146
+ JRuby runtime management and pooling is done automatically by the framework.
147
+ In the case of Rails, runtimes are pooled. For other Rack applications,
148
+ currently, a single runtime is created and shared for every request.
141
149
 
142
150
  ## JRuby-Rack Configuration
143
151
 
144
152
  JRuby-Rack can be configured by setting these key value pairs either
145
153
  as context init parameters in web.xml or as VM-wide system properties.
146
154
 
147
- - `rackup`: Rackup script for configuring how the Rack application is
148
- mounted. Required for Rack-based applications other than Rails or
149
- Merb. Can be omitted if a `config.ru` is included in the application
150
- root.
151
- - `jruby.min.runtimes`: For non-threadsafe Rails applications using a
152
- runtime pool, specify an integer minimum number of runtimes to hold
153
- in the pool.
154
- - `jruby.max.runtimes`: For non-threadsafe Rails applications, an
155
- integer maximum number of runtimes to keep in the pool.
156
- - `jruby.init.serial`: When using runtime pooling, indicate that the
157
- runtime pool should be created serially in the foreground rather
158
- than spawning background threads. For environments where creating
159
- threads is not permitted.
160
- - `jruby.compat.version`: Set to "1.8" or "1.9" to make JRuby run a
161
- specific version of Ruby.
162
- - `public.root`: Relative path to the location of your application's
163
- static assets. Defaults to `/`.
155
+ - `rackup`: Rackup script for configuring how the Rack application is mounted.
156
+ Required for Rack-based applications other than Rails. Can be omitted if a
157
+ *config.ru* is included in the application root.
158
+ - `jruby.min.runtimes`: For non-threadsafe Rails applications using a runtime
159
+ pool, specify an integer minimum number of runtimes to hold in the pool.
160
+ - `jruby.max.runtimes`: For non-threadsafe Rails applications, an integer
161
+ maximum number of runtimes to keep in the pool.
162
+ - `jruby.init.serial`: When using runtime pooling, indicate that the runtime
163
+ pool should be created serially in the foreground rather than spawning
164
+ background threads. For environments where creating threads is not permitted.
165
+ - `jruby.compat.version`: Set to "1.8" or "1.9" to make JRuby run a specific
166
+ version of Ruby.
167
+ - `public.root`: Relative path to the location of your application's static
168
+ assets. Defaults to */*.
164
169
  - `gem.path`: Relative path to the bundled gem repository. Defaults to
165
- `/WEB-INF/gems`.
166
- - `rails.root`, `merb.root`: Root path to the location of the Rails or
167
- Merb application files. Defaults to `/WEB-INF`.
168
- - `rails.env`: Specify the Rails environment to run. Defaults
169
- to 'production'.
170
+ */WEB-INF/gems*.
171
+ - `rails.root`: Root path to the location of the Rails application files.
172
+ Defaults to */WEB-INF*.
173
+ - `rails.env`: Specify the Rails environment to run. Defaults to 'production'.
170
174
  - `rails.relative_url_append`: Specify a path to be appended to the
171
- ActionController::Base.relative_url_root after the context path. Useful
172
- for running a rails app from the same war as an existing app, under
173
- a sub-path of the main servlet context root.
174
- - `merb.environment`: Specify the merb environment to run. Defaults to
175
- `production`.
175
+ `ActionController::Base.relative_url_root` after the context path. Useful
176
+ for running a rails app from the same war as an existing app, under a
177
+ sub-path of the main servlet context root.
176
178
  - `jruby.rack.logging`: Specify the logging device to use. Defaults to
177
179
  `servlet_context`. See below.
180
+ - `jruby.rack.ignore.env`: Clears out the `ENV` hash in each runtime to insulate
181
+ the application from the environment.
178
182
  - `jruby.rack.background.spool`: (EXPERIMENTAL) Enable large request
179
183
  bodies to be spooled to a tempfile in the background.
180
- - `jruby.rack.filter.adds.html`: The default behavior for Rails and
181
- many other Ruby applications is to add an .html extension to the
182
- resource and attempt to handle it before serving a dynamic request
183
- on the original URI. However, this behavior may confuse other
184
- servlets in your application that have a wildcard mapping. Defaults
185
- to true.
186
- - `jruby.rack.filter.verify.resource.exists`: If
187
- `jruby.rack.filter.adds.html` is true, then this setting, when true,
188
- adds an additional check using `ServletContext#getResource` to
189
- verify that the .html resource exists. Default is false. (Note that
190
- apparently some servers may not implement `getResource` in the way
184
+ - `jruby.rack.filter.adds.html`:
185
+ **deprecated** use `addsHtmlToPathInfo` filter config init parameter.
186
+ The default behavior for Rails and many other Ruby applications is to add an
187
+ *.html* extension to the resource and attempt to handle it before serving a
188
+ dynamic request on the original URI.
189
+ However, this behavior may confuse other servlets in your application that
190
+ have a wildcard mapping. Defaults to true.
191
+ - `jruby.rack.filter.verify.resource.exists`:
192
+ **deprecated** use `verifiesHtmlResource` filter config init parameter.
193
+ If `jruby.rack.filter.adds.html` is true, then this setting, when true, adds
194
+ an additional check using `ServletContext#getResource` to verify that the
195
+ *.html* resource exists. Default is false.
196
+ (Note that apparently some servers may not implement `getResource` in the way
191
197
  that is expected here, so in that case this setting won't matter.)
192
- - `jruby.rack.ignore.env`: Clears out the ENV hash in each runtime to
193
- insulate the application from the environment.
194
198
 
195
199
  ## Initialization
196
200
 
197
- There are often cases where you need to perform custom initialization
198
- of the Ruby environment before booting the application. You can create
199
- a file called `META-INF/init.rb` or `WEB-INF/init.rb` inside the war
200
- file for this purpose. These files, if found, will be evaluated before
201
- booting the Rack environment, allowing you to set environment
202
- variables, load scripts, etc.
201
+ There are often cases where you need to perform custom initialization of the
202
+ Ruby environment before booting the application. You can create a file called
203
+ *META-INF/init.rb* or *WEB-INF/init.rb* inside the war file for this purpose.
204
+ These files, if found, will be evaluated before booting the Rack environment,
205
+ allowing you to set environment variables, load scripts, etc.
203
206
 
204
207
  ## Logging
205
208
 
206
- JRuby-Rack sets up a delegate logger for Rails that sends logging
207
- output to `javax.servlet.ServletContext#log` by default. If you wish
208
- to use a different logging system, configure `jruby.rack.logging` as
209
- follows:
209
+ JRuby-Rack sets up a delegate logger for Rails that sends logging output to
210
+ `javax.servlet.ServletContext#log` by default. If you wish to use a different
211
+ logging system, configure `jruby.rack.logging` as follows:
210
212
 
211
- - `servlet_context` (default): Sends log messages to the servlet
212
- context.
213
- - `stdout`: Sends log messages to the standard output stream
214
- `System.out`.
213
+ - `servlet_context` (default): Sends log messages to the servlet context.
214
+ - `stdout`: Sends log messages to the standard output stream `System.out`.
215
215
  - `commons_logging`: Sends log messages to Apache commons-logging. You
216
216
  still need to configure commons-logging with additional details.
217
217
  - `slf4j`: Sends log messages to SLF4J. Again, SLF4J configuration is
218
218
  left up to you.
219
- - `log4j`: Sends log messages to log4J. Again, log4J configuration is
219
+ - `log4j`: Sends log messages to log4J. Again, Log4J configuration is
220
220
  left up to you.
221
221
 
222
222
  For those loggers that require a specific named logger, set it in the
@@ -269,10 +269,9 @@ the following:
269
269
  ## Rails Step-by-step
270
270
 
271
271
  This example shows how to create and deploy a simple Rails app using
272
- the embedded Java database H2 to a WAR using Warble and JRuby Rack.
272
+ the embedded Java database H2 to a WAR using Warbler and JRuby-Rack.
273
273
 
274
- Install Rails and the driver and ActiveRecord adapters for the H2
275
- database:
274
+ Install Rails and the ActiveRecord adapters + driver for the H2 database:
276
275
 
277
276
  jruby -S gem install rails activerecord-jdbch2-adapter
278
277
 
@@ -301,7 +300,7 @@ Copy this configuration into config/database.yml:
301
300
 
302
301
  Add the following to your application's Gemfile:
303
302
 
304
- gem 'activerecord-jdbch2-adapter'
303
+ gem 'activerecord-jdbch2-adapter', :platform => :jruby
305
304
 
306
305
  Generate a scaffold for a simple model of blog comments.
307
306
 
@@ -311,37 +310,33 @@ Run the database migration that was just created as part of the scaffold.
311
310
 
312
311
  jruby -S rake db:migrate
313
312
 
314
- Start your application on the Rails default port 3000 using WEBrick
315
- and make sure it works:
313
+ Start your application on 3000 using WEBrick and make sure it works:
316
314
 
317
315
  jruby script/rails server
318
316
 
319
- Generate a custom Warbler WAR configuration for the blog application
317
+ Generate a production version of the H2 database for the application:
320
318
 
321
- jruby -S warble config
319
+ RAILS_ENV=production jruby -S rake db:migrate
322
320
 
323
- Generate a production version of the H2 database for the blog
324
- application:
321
+ Generate a custom Warbler WAR configuration for the blog application
325
322
 
326
- RAILS_ENV=production jruby -S rake db:migrate
323
+ jruby -S warble config
327
324
 
328
- Edit this file: config/warble.rb and add the following line after
329
- these comments:
325
+ Edit *config/warble.rb* and add the following line after these comments:
330
326
 
331
327
  # Additional files/directories to include, above those in config.dirs
332
328
  # config.includes = FileList["db"]
333
329
  config.includes = FileList["db/production_h2*"]
334
330
 
335
- This will tell Warble to include the just initialized production H2
331
+ This will tell Warbler to include the just initialized production H2
336
332
  database in the WAR.
337
333
 
338
334
  Now generate the WAR file:
339
335
 
340
336
  jruby -S warble war
341
337
 
342
- This task generates the file: blog.war at the top level of the
343
- application as well as an exploded version of the war located here:
344
- tmp/war.
338
+ This task generates the file: blog.war at the top level of the application as
339
+ well as an exploded version of the war located at *tmp/war*.
345
340
 
346
341
  The war should be ready to deploy to your Java application server.
347
342
 
Binary file
@@ -7,6 +7,6 @@
7
7
 
8
8
  module JRuby
9
9
  module Rack
10
- VERSION = "1.1.4"
10
+ VERSION = "1.1.5"
11
11
  end
12
12
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jruby-rack
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.4
5
+ version: 1.1.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nick Sieger
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-02-21 00:00:00 Z
13
+ date: 2012-04-03 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: JRuby-Rack is a combined Java and Ruby library that adapts the Java Servlet API to Rack. For JRuby only.
@@ -23,11 +23,11 @@ extensions: []
23
23
  extra_rdoc_files: []
24
24
 
25
25
  files:
26
- - History.txt
27
- - LICENSE.txt
28
26
  - README.md
29
- - lib/jruby-rack-1.1.4.jar
27
+ - LICENSE.txt
28
+ - History.txt
30
29
  - lib/jruby-rack.rb
30
+ - lib/jruby-rack-1.1.5.jar
31
31
  - lib/jruby/rack/version.rb
32
32
  homepage: http://jruby.org
33
33
  licenses: []
Binary file