jruby-rack 1.1.10 → 1.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,53 @@
1
+ == 1.1.12 (28/11/12)
2
+
3
+ - make (Default)Env to be the environment Hash instance itself since we need
4
+ to handle custom lazy-bound keys but can not use a default proc (#132)
5
+ - support the renew (and skip) session option with servlet store (#131)
6
+ - improve ENV isolation with booted Ruby runtimes
7
+ - jruby.rack.env replaces jruby.rack.ignore.env (now deprecated)
8
+ - make sure RUBYOPT is ignored (with backwards compat)
9
+ - jruby.rack.env.rubyopt for finer RUBYOPT behavior control
10
+ - allow env value to be specified from config
11
+ - solve the rackup "chicken - egg" problem with a plain Rack app
12
+ - with a magic comment in config.ru # rack.version: ~>1.3.6
13
+ - for bundle exec "emulation" use # rack.version: bundler
14
+ - (temporarily) introduce RackEnvironment.ToIO to avoid instance vars
15
+ on non-persistent Java types (JRuby 1.7 warning)
16
+ - add a JRuby::Rack::Helpers module for helper functions
17
+ - decorating factories (e.g. pooling factory) can now be distinguished
18
+ - refactored / updated error handling :
19
+ - move the decision about throwing the init error into the listener
20
+ - unify exception handling across decorating app factories with support
21
+ for configuring exception handling with the *jruby.rack.error* option
22
+ - make sure init errors are thrown from pooling factory's init
23
+ - added an ErrorApplication marker interface
24
+ - dispatcher might now decide what status to return (or throw)
25
+ - let the servlet container deal with null response header values
26
+ - expose the rack context using JRuby::Rack.context= in embed scenario
27
+ - rely less on booter and $servlet_context whenever possible
28
+ - moved Booter#logger into JRuby::Rack.logger
29
+ - boot! now 'exports' JRuby::Rack.app_path and public_path
30
+ - changed $servlet_context refs to JRuby::Rack.context
31
+ - maven + rake (joint) build review
32
+ run mvn compile on rake compile instead of custom javac
33
+ (+ updated jruby.version to 1.6.8)
34
+ - removed LoggerConfigurationException used with Commons-Logging
35
+ - fix invalid /tmp detected jruby home LOAD_PATH on 1.7.0
36
+ - support setting compat version 2.0 (on JRuby 1.7.x)
37
+ - application layout (JRuby::Rack::AppLayout) improvements :
38
+ - introduce app.root context param (similar to rails.root)
39
+ - RailsWebInfLayout is now the same as WebInfLayout
40
+ - added (generic) FileSystemLayout (handles rails apps as well)
41
+ - RailsFilesystemLayout is FileSystemLayout for compatibility
42
+ - make sure paths are expanded when using a FS layout
43
+ - moved change_working_directory code to happen within Booter
44
+ - fix Booter failing to boot! when layout.gem_path nil (or empty)
45
+ - Rails booter's RAILS_ENV should default to RACK_ENV if set
46
+ - make sure original rack body gets always closed with optimized send_file
47
+ might lead to side-effects such as not releasing database connections (#123)
48
+ - some more useful Servlet API Ruby extensions ('attribute' managing objects
49
+ such as ServletContext behave similar to Hash)
50
+
1
51
  == 1.1.10 (04/09/12)
2
52
 
3
53
  - correctly dechunk data from response and handle flushing,
data/LICENSE.txt CHANGED
@@ -1,6 +1,7 @@
1
1
  #--
2
2
  # The MIT License
3
3
  #
4
+ # Copyright (c) 2012 Karol Bucek
4
5
  # Copyright (c) 2010-2012 Engine Yard, Inc.
5
6
  # Copyright (c) 2007-2009 Sun Microsystems, Inc.
6
7
  #
data/README.md CHANGED
@@ -1,35 +1,38 @@
1
1
  # JRuby-Rack
2
2
 
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.
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
5
  JRuby-Rack supports Rails as well as any Rack-compatible Ruby web framework.
6
6
 
7
7
  For more information on Rack, visit http://rack.rubyforge.org.
8
8
 
9
- [![Build Status](https://secure.travis-ci.org/jruby/jruby-rack.png?branch=master)](http://travis-ci.org/jruby/jruby-rack)
9
+ [![Build Status][0]](http://travis-ci.org/jruby/jruby-rack)
10
10
 
11
- # Getting Started
11
+ ## Getting Started
12
12
 
13
- The easiest way to use JRuby-Rack is to get [Warbler][1].
13
+ The most-common way to use JRuby-Rack is to get [Warbler][1].
14
14
  Warbler depends on the latest version of JRuby-Rack and ensures it gets placed
15
15
  in your WAR file when it gets built.
16
16
 
17
17
  If you're assembling your own WAR using other means, you can install the
18
18
  **jruby-rack** gem. It provides a method to locate the jar file:
19
19
 
20
- require 'fileutils'
21
20
  require 'jruby-rack'
22
21
  FileUtils.cp JRubyJars.jruby_rack_jar_path, '.'
23
22
 
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.
23
+ Otherwise you'll need to download the latest [jar release][2], drop it into the
24
+ *WEB-INF/lib* directory and configure the `RackFilter` in your application's
25
+ *web.xml* (see following examples).
27
26
 
28
- ## For Rails
27
+ Alternatively you can use a server built upon JRuby-Rack such as [Trinidad][3]
28
+ with sensible defaults, without the need to configure a deployment descriptor.
29
29
 
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.
30
+ ### Rails
31
+
32
+ Here's sample *web.xml* configuration for Rails. Note the environment and
33
+ min/max runtime parameters. For **multi-threaded** (a.k.a. `thread-safe!`)
34
+ Rails with a single runtime, set min/max both to 1. Otherwise, define the size
35
+ of the runtime pool as you wish.
33
36
 
34
37
  <context-param>
35
38
  <param-name>rails.env</param-name>
@@ -70,15 +73,16 @@ both to 1. Otherwise, define the size of the runtime pool as you wish.
70
73
  <listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
71
74
  </listener>
72
75
 
73
- ## For Other Rack Applications
76
+ ### (Other) Rack Applications
74
77
 
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`.
78
+ The main difference when using a non-Rails Rack application is that JRuby-Rack
79
+ looks for a "rackup" file named **config.ru** in `WEB-INF/config.ru` or
80
+ `WEB-INF/*/config.ru`. Here's a sample *web.xml* configuration :
78
81
 
79
82
  <filter>
80
83
  <filter-name>RackFilter</filter-name>
81
84
  <filter-class>org.jruby.rack.RackFilter</filter-class>
85
+ <!-- optional filter configuration init-params (@see above) -->
82
86
  </filter>
83
87
  <filter-mapping>
84
88
  <filter-name>RackFilter</filter-name>
@@ -89,10 +93,8 @@ is that JRuby-Rack looks for a "rackup" file named **config.ru** in
89
93
  <listener-class>org.jruby.rack.RackServletContextListener</listener-class>
90
94
  </listener>
91
95
 
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 !
96
+ If you don't have a *config.ru* or don't want to include it in your web app, you
97
+ can embed it directly in the *web.xml* as follows (using Sinatra as an example):
96
98
 
97
99
  <context-param>
98
100
  <param-name>rackup</param-name>
@@ -106,38 +108,50 @@ Be sure to escape angle-brackets for XML !
106
108
  </param-value>
107
109
  </context-param>
108
110
 
111
+ Be sure to escape angle-brackets for XML !
109
112
 
110
- # Features
111
113
 
112
114
  ## Servlet Filter
113
115
 
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
+ JRuby-Rack's main mode of operation is as a filter. This allows requests for
117
+ static content to pass through and be served by the application server.
116
118
  Dynamic requests only happen for URLs that don't have a corresponding file, much
117
- like many Ruby applications expect.
119
+ like many Ruby/Rack applications expect. The (default) filter we recommend
120
+ using is `org.jruby.rack.RackFilter`, the filter supports the following
121
+ (optional) init-params:
122
+
123
+ - **responseNotHandledStatuses** which statuses (when a filter chain returns)
124
+ should be considered that the response has not been handled (default value:
125
+ "403,404,405") and should be dispatched as a Rack application
126
+ - **resetUnhandledResponse** whether an unhandled response from the filter chain
127
+ gets reset (accepts values "true", "false" and "buffer" to reset the buffer
128
+ only), by default "true"
129
+ - **addsHtmlToPathInfo** controls whether the .html suffix is added to the URI
130
+ when checking if the request is for a static page
131
+ - **verifiesHtmlResource** used with the previous parameter to makee sure the
132
+ requested static resource exist before adding the .html request URI suffix
133
+
118
134
  The application can also be configured to dispatch through a servlet instead of
119
- a filter if it suits your environment better.
135
+ a filter, the servlet class name is `org.jruby.rack.RackServlet`.
120
136
 
121
- ## Servlet environment integration
137
+ ## Servlet Environment Integration
122
138
 
123
- - Servlet context is accessible to any application through the Rack environment
124
- variable *java.servlet_context* as well as the `$servlet_context` global.
125
- - Servlet request object is available in the Rack environment via the
126
- key *java.servlet_request*.
127
- - Servlet request attributes are passed through to the Rack environment.
128
- - Rack environment variables and headers can be overridden by servlet
129
- request attributes.
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.
139
+ - servlet context is accessible to any application through the Rack environment
140
+ variable *java.servlet_context* (as well as the `$servlet_context` global).
141
+ - the (native) servlet request and response objects could be obtained via the
142
+ *java.servlet_request* and *java.servlet_response* keys
143
+ - all servlet request attributes are passed through to the Rack environment (and
144
+ thus might override request headers or Rack environment variables)
145
+ - servlet sessions can be used as a (java) session store for Rails, session
146
+ attributes with String keys (and String, numeric, boolean, or java
147
+ object values) are automatically copied to the servlet session for you.
133
148
 
134
149
  ## Rails
135
150
 
136
151
  Several aspects of Rails are automatically set up for you.
137
152
 
138
- - The Rails controller setting `ActionController::Base.relative_url_root`
139
- is set for you automatically according to the context root where
140
- your webapp is deployed.
153
+ - `ActionController::Base.relative_url_root` is set for you automatically
154
+ according to the context root where your webapp is deployed.
141
155
  - `Rails.logger` output is redirected to the application server log.
142
156
  - Page caching and asset directories are configured appropriately.
143
157
 
@@ -146,9 +160,15 @@ Several aspects of Rails are automatically set up for you.
146
160
  JRuby runtime management and pooling is done automatically by the framework.
147
161
  In the case of Rails, runtimes are pooled by default (the default will most
148
162
  likely change with the adoption of Rails 4.0). For other Rack applications a
149
- single shared runtime is created and shared for every request by default (as of
150
- **1.1.9** if *jruby.min.runtimes*/*jruby.max.runtimes* values are specified
151
- pooling is supported as well).
163
+ single shared runtime is created and shared for every request by default.
164
+ As of **1.1.9** if *jruby.min.runtimes* and *jruby.max.runtimes* values are
165
+ specified pooling is supported for plain Rack applications as well.
166
+
167
+ We do recommend to boot your runtimes up-front to avoid the cost of initializing
168
+ one while a request kicks in and find the pool empty, this can be easily avoided
169
+ by setting *jruby.min.runtimes* equal to *jruby.max.runtimes*. You might also
170
+ want to consider tunning the *jruby.runtime.acquire.timeout* parameter to not
171
+ wait too long when all (max) runtimes from the pool are busy.
152
172
 
153
173
  ## JRuby-Rack Configuration
154
174
 
@@ -186,10 +206,15 @@ as context init parameters in web.xml or as VM-wide system properties.
186
206
  when acquiring a runtime from the pool (while a pool maximum is set), an
187
207
  exception will be thrown if a runtime can not be acquired within this time (
188
208
  accepts decimal values for fine tuning e.g. 1.25).
209
+ - `jruby.runtime.env`: Allows to set a custom ENV hash for your Ruby environment
210
+ and thus insulate the application from the environment it is running. By setting
211
+ this option to en empty string (or 'false') it acts as if the ENV hash was
212
+ cleared out (similar to the now deprecated `jruby.rack.ignore.env` option).
213
+ - `jruby.runtime.env.rubyopt`: This option is used for compatibility with the
214
+ (deprecated) `jruby.rack.ignore.env` option since it cleared out the ENV after
215
+ RUBYOPT has been processed, by setting it to true ENV['RUBYOPT'] will be kept.
189
216
  - `jruby.rack.logging`: Specify the logging device to use. Defaults to
190
217
  `servlet_context`. See below.
191
- - `jruby.rack.ignore.env`: Clears out the `ENV` hash in each runtime to insulate
192
- the application from the environment.
193
218
  - `jruby.rack.request.size.initial.bytes`: Initial size for request body memory
194
219
  buffer, see also `jruby.rack.request.size.maximum.bytes` bellow.
195
220
  - `jruby.rack.request.size.maximum.bytes`: The maximum size for the request in
@@ -199,6 +224,13 @@ as context init parameters in web.xml or as VM-wide system properties.
199
224
  as frameworks such as Rails might use `Rack::Chunked::Body` as a Rack response
200
225
  body but since most servlet containers perform dechunking automatically things
201
226
  might end double-chunked in such cases.
227
+ - `jruby.rack.handler.env`: **EXPERIMENTAL** Allows to change Rack's behavior
228
+ on obtaining the Rack environment. The default behavior is that parameter
229
+ parsing is left to be done by the Rack::Request itself (by consuming the
230
+ request body in case of a POST), but if the servlet request's input stream has
231
+ been previously read this leads to a limitation (Rack won't see the POST paras).
232
+ Thus an alternate pure 'servlet' env "conversion" is provided that maps servlet
233
+ parameters (and cookies) directly to Rack params, avoiding Rack's input parsing.
202
234
  - `jruby.rack.filter.adds.html`:
203
235
  **deprecated** use `addsHtmlToPathInfo` filter config init parameter.
204
236
  The default behavior for Rails and many other Ruby applications is to add an
@@ -222,6 +254,22 @@ Ruby environment before booting the application. You can create a file called
222
254
  These files, if found, will be evaluated before booting the Rack environment,
223
255
  allowing you to set environment variables, load scripts, etc.
224
256
 
257
+ For plain Rack applications, JRuby-Rack also supports a magic comment to solve
258
+ the "rackup" chicken-egg problem (you need Rack's builder loaded before loading
259
+ the *config.ru*, yet you may want to setup the gem version from within the rackup
260
+ file). As we ship with the Rack gem bundled, otherwise when executing the
261
+ provided *config.ru* the bundled (latest) version of Rack will get loaded.
262
+
263
+ Use **rack.version** to specify the Rack gem version to be loaded before rackup :
264
+
265
+ # encoding: UTF-8
266
+ # rack.version: ~>1.3.6 (before code is loaded gem '~>1.3.6' will be called)
267
+
268
+ Or the equivalent of doing `bundle exec rackup ...` if you're using Bundler :
269
+
270
+ # rack.version: bundler (requires 'bundler/setup' before loading the script)
271
+
272
+
225
273
  ## Logging
226
274
 
227
275
  JRuby-Rack sets up a delegate logger for Rails that sends logging output to
@@ -242,132 +290,41 @@ logging system, configure `jruby.rack.logging` as follows:
242
290
  For those loggers that require a specific named logger, set it with the
243
291
  `jruby.rack.logging.name` option, by default "jruby.rack" name will be used.
244
292
 
245
- # Building
293
+ ## Building
246
294
 
247
- Checkout the JRuby Rack code and cd to that directory.
295
+ Checkout the JRuby-Rack code using [git](http://git-scm.com/) :
248
296
 
249
297
  git clone git://github.com/jruby/jruby-rack.git
250
298
  cd jruby-rack
251
299
 
252
- Ensure you have Maven installed. It is required for downloading jar
253
- artifacts that JRuby-Rack depends on.
300
+ Ensure you have [Maven](http://maven.apache.org/) installed.
301
+ It is required for downloading jar artifacts that JRuby-Rack depends on.
254
302
 
255
- You can choose to build with either Maven or Rake. Either of the
256
- following two will suffice.
303
+ Build the .jar using Maven :
257
304
 
258
305
  mvn install
259
- jruby -S rake
260
-
261
- The generated jar should be located here: target/jruby-rack-*.jar.
262
-
263
- # Issues
264
-
265
- Please use GitHub to file bugs, patches and pull requests.
266
-
267
- - https://github.com/jruby/jruby-rack
268
- - https://github.com/jruby/jruby-rack/issues
269
-
270
- # Releases
271
-
272
- For JRuby-Rack contributors, the release process goes something like
273
- the following:
274
-
275
- 1. Ensure that release version is correct in _pom.xml_ and `mvn install`
276
- runs clean.
277
- 2. Ensure generated changes to _src/main/ruby/jruby/rack/version.rb_ are
278
- checked in.
279
- 3. Ensure _History.txt_ is updated with latest release information.
280
- 3. Tag current release in git: `git tag <version>`.
281
- 4. Push commits and tag: `git push origin master --tags`
282
- 5. Build gem: `rake clean gem`
283
- 6. Push gem: `gem push target/jruby-rack-*.gem`
284
- 7. Release jar to maven repository: `mvn -DupdateReleaseInfo=true deploy`
285
- 8. Bump the version in _pom.xml_ to next release version *X.X.X.dev-SNAPSHOT*,
286
- run `mvn install`, and commit the changes.
287
-
288
- ## Rails Step-by-step
289
-
290
- This example shows how to create and deploy a simple Rails app using
291
- the embedded Java database H2 to a WAR using Warbler and JRuby-Rack.
292
-
293
- Install Rails and the ActiveRecord adapters + driver for the H2 database:
294
-
295
- jruby -S gem install rails activerecord-jdbch2-adapter
296
-
297
- Install Warbler:
298
-
299
- jruby -S gem install warbler
300
-
301
- Make the "Blog" application
302
-
303
- jruby -S rails new blog
304
- cd blog
305
-
306
- Copy this configuration into config/database.yml:
307
-
308
- development:
309
- adapter: jdbch2
310
- database: db/development_h2_database
311
-
312
- test:
313
- adapter: jdbch2
314
- database: db/test_h2_database
315
-
316
- production:
317
- adapter: jdbch2
318
- database: db/production_h2_database
319
-
320
- Add the following to your application's Gemfile:
321
-
322
- gem 'activerecord-jdbch2-adapter', :platform => :jruby
323
-
324
- Generate a scaffold for a simple model of blog comments.
325
-
326
- jruby script/rails generate scaffold comment name:string body:text
327
-
328
- Run the database migration that was just created as part of the scaffold.
329
-
330
- jruby -S rake db:migrate
331
-
332
- Start your application on 3000 using WEBrick and make sure it works:
333
-
334
- jruby script/rails server
335
-
336
- Generate a production version of the H2 database for the application:
337
-
338
- RAILS_ENV=production jruby -S rake db:migrate
339
-
340
- Generate a custom Warbler WAR configuration for the blog application
341
-
342
- jruby -S warble config
343
-
344
- Edit *config/warble.rb* and add the following line after these comments:
345
306
 
346
- # Additional files/directories to include, above those in config.dirs
347
- # config.includes = FileList["db"]
348
- config.includes = FileList["db/production_h2*"]
307
+ the generated jar should be located at **target/jruby-rack-*.jar**
349
308
 
350
- This will tell Warbler to include the just initialized production H2
351
- database in the WAR.
309
+ Alternatively use Rake, e.g. to build the gem (skipping specs) :
352
310
 
353
- Now generate the WAR file:
311
+ jruby -S rake clean gem SKIP_SPECS=true
354
312
 
355
- jruby -S warble war
313
+ You can **not** use JRuby-Rack with Bundler directly from the git (or http) URL
314
+ (`gem 'jruby-rack', :github => 'jruby/jruby-rack'`) since the included .jar file
315
+ is compiled and generated on-demand during the build (it would require us to
316
+ package and push the .jar every time a commit changes a source file).
356
317
 
357
- This task generates the file: blog.war at the top level of the application as
358
- well as an exploded version of the war located at *tmp/war*.
359
318
 
360
- The war should be ready to deploy to your Java application server.
319
+ ## Issues
361
320
 
362
- # Thanks
321
+ Please use [github][4] to file bugs, patches and pull requests.
363
322
 
364
- - All contributors! But also:
365
- - Dudley Flanders, for the Merb support
366
- - Robert Egglestone, for the original JRuby servlet integration
367
- project, Goldspike
368
- - Chris Neukirchen, for Rack
369
- - Sun Microsystems, for early project support
370
- - Engine Yard, for more recent support
323
+ More information at the [wiki][5] or ask us at the #jruby IRC channel.
371
324
 
325
+ [0]: https://secure.travis-ci.org/jruby/jruby-rack.png?branch=master
372
326
  [1]: http://caldersphere.rubyforge.org/warbler
373
327
  [2]: http://repository.codehaus.org/org/jruby/rack/jruby-rack/
328
+ [3]: http://github.com/trinidad/trinidad
329
+ [4]: http://github.com/jruby/jruby-rack/issues
330
+ [5]: http://wiki.github.com/jruby/jruby-rack
Binary file
@@ -7,6 +7,6 @@
7
7
 
8
8
  module JRuby
9
9
  module Rack
10
- VERSION = "1.1.10"
10
+ VERSION = "1.1.12"
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.10
5
+ version: 1.1.12
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-09-04 00:00:00 Z
13
+ date: 2012-11-28 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
- - README.md
27
- - LICENSE.txt
28
26
  - History.txt
27
+ - LICENSE.txt
28
+ - README.md
29
+ - lib/jruby-rack-1.1.12.jar
29
30
  - lib/jruby-rack.rb
30
- - lib/jruby-rack-1.1.10.jar
31
31
  - lib/jruby/rack/version.rb
32
32
  homepage: http://jruby.org
33
33
  licenses: []
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  requirements: []
56
56
 
57
57
  rubyforge_project: jruby-extras
58
- rubygems_version: 1.8.15
58
+ rubygems_version: 1.8.24
59
59
  signing_key:
60
60
  specification_version: 3
61
61
  summary: Rack adapter for JRuby and Servlet Containers
Binary file