jetty-rails 0.5 → 0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,12 @@
1
+ == 0.6
2
+ * load all java classes inside classes/ by default
3
+ * command line args to customize lib/ and classes/ directories
4
+ * -v showing jetty_rails version
5
+ * each web application context has its own classloader (isolated classpaths)
6
+ * upgraded to jruby-rack-0.9.2 (no more views being cached in development time)
7
+ * minor changes and refactorings
8
+ * improved docs for multi-server support
9
+
1
10
  == 0.5
2
11
  * load all jars inside lib/ by default
3
12
  * using GEM_PATH environment variable, if exists
@@ -4,6 +4,7 @@ Manifest.txt
4
4
  PostInstall.txt
5
5
  README.txt
6
6
  Rakefile
7
+ TODO.txt
7
8
  bin/jetty_merb
8
9
  bin/jetty_rails
9
10
  config/hoe.rb
@@ -12,26 +13,37 @@ lib/jetty-6.1.9.jar
12
13
  lib/jetty-plus-6.1.9.jar
13
14
  lib/jetty-util-6.1.9.jar
14
15
  lib/jetty_rails.rb
16
+ lib/jetty_rails/adapters/abstract_adapter.rb
15
17
  lib/jetty_rails/adapters/merb_adapter.rb
16
18
  lib/jetty_rails/adapters/rails_adapter.rb
19
+ lib/jetty_rails/config/command_line_reader.rb
20
+ lib/jetty_rails/config/rdoc_fix.rb
17
21
  lib/jetty_rails/handler/delegate_on_errors_handler.rb
22
+ lib/jetty_rails/handler/public_directory_handler.rb
23
+ lib/jetty_rails/handler/web_app_handler.rb
18
24
  lib/jetty_rails/jars.rb
19
25
  lib/jetty_rails/runner.rb
26
+ lib/jetty_rails/server.rb
20
27
  lib/jetty_rails/version.rb
21
- lib/jruby-rack-0.9.jar
28
+ lib/jetty_rails/warbler_reader.rb
29
+ lib/jruby-rack-0.9.2.jar
22
30
  lib/servlet-api-2.5-6.1.9.jar
23
31
  script/console
24
32
  script/destroy
25
33
  script/generate
26
34
  script/txt2html
27
35
  setup.rb
36
+ spec/config.yml
28
37
  spec/jetty_merb_spec.rb
38
+ spec/jetty_rails/config_file_spec.rb
29
39
  spec/jetty_rails/handler/delegate_on_errors_handler_spec.rb
30
40
  spec/jetty_rails/runner_spec.rb
41
+ spec/jetty_rails_sample_1.yml
42
+ spec/jetty_rails_sample_2.yml
31
43
  spec/jetty_rails_spec.rb
32
44
  spec/spec.opts
33
45
  spec/spec_helper.rb
34
46
  tasks/deployment.rake
35
47
  tasks/environment.rake
36
48
  tasks/rspec.rake
37
- tasks/website.rake
49
+ tasks/website.rake
data/README.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  = jetty-rails
2
2
 
3
- jetty-rails.rubyforge.net
3
+ http://jetty-rails.rubyforge.net
4
4
 
5
5
  == DESCRIPTION:
6
6
 
@@ -14,6 +14,7 @@ The project has born from my own needs. I needed to run JForum (http://jforum.ne
14
14
 
15
15
  * Uses {JRuby Rack}[http://wiki.jruby.org/wiki/JRuby_Rack].
16
16
  * Loads all jars inside your application lib/ dir, by default.
17
+ * Loads all classes inside your application classes/ dir, by default.
17
18
  * Supports rails and merb applications out of the box.
18
19
 
19
20
  == KNOWN ISSUES
@@ -30,7 +31,7 @@ jruby -S rake rcov
30
31
  cd myrailsapp
31
32
  jruby -S jetty_rails
32
33
 
33
- --help option shows usage details:
34
+ help option shows usage details:
34
35
 
35
36
  jruby -S jetty_rails --help
36
37
 
@@ -39,9 +40,19 @@ jruby -S rake rcov
39
40
  cd mymerbapp
40
41
  jruby -S jetty_merb
41
42
 
42
- --help option shows usage details:
43
+ help option shows usage details:
44
+
45
+ jruby -S jetty_merb --help
46
+
47
+ === Merb:
48
+
49
+ cd mymerbapp
50
+ jruby -S jetty_merb
51
+
52
+ help option shows usage details:
53
+
54
+ jruby -S jetty_merb --help
43
55
 
44
- jruby -S jetty_rails --help
45
56
 
46
57
  == REQUIREMENTS:
47
58
 
@@ -53,6 +64,67 @@ it properly installed and inserted in your PATH environment variable.
53
64
  == INSTALL:
54
65
 
55
66
  jruby -S gem install jetty-rails
67
+
68
+ == BUGS AND NEW FEATURES
69
+
70
+ Using Lighthouse: http://fabiokung.lighthouseapp.com/projects/12666-jetty-rails
71
+
72
+
73
+ == MULTIPLE SERVERS:
74
+
75
+ You can specify a configuration yaml file rather than command line switches.
76
+ The file also allows specifying multiple servers and / or application contexts for single jetty container.
77
+
78
+ For example, you could set a context_path of /testA on port 8888 which is rails, /testB also that port which is merb.
79
+ Or, you could have /testA on port 8888 and /testB on port 9999.
80
+
81
+ jruby -S jetty_rails -c path/to/config.yml
82
+
83
+ The configuration options are inherited, so if you specify the environment to be "production" at the top level,
84
+ then any servers and application context will be "production" unless the choose to override the value.
85
+
86
+ - server settings:
87
+ <tt>:port</tt>, <tt>:jruby_min_runtimes</tt>, <tt>:jruby_max_runtimes</tt>, <tt>:thread_pool_max</tt>, <tt>:thread_pool_min</tt>, <tt>:acceptor_size</tt>
88
+
89
+ - application context settings:
90
+ <tt>:context_path</tt>, <tt>:base</tt>, <tt>:adapter</tt>, <tt>:environment</tt>, <tt>:lib_dir</tt>, <tt>:gem_path</tt>
91
+
92
+ As part of the configuration you have some control over jruby & jetty.
93
+
94
+ See spec/config.yml, spec/jetty_rails_sample_1.yml, and spec/jetty_rails_sample_2.yml for more examples.
95
+
96
+ === Rails:
97
+
98
+ If -c is not specified, by default jetty_rails will look for a config/jetty_rails.yml relative to where it is started.
99
+
100
+ Don't forget to add this into your config/environment.rb
101
+ ActionController::AbstractRequest.relative_url_root = "/testA"
102
+
103
+
104
+ === JRuby Configuration
105
+
106
+ You can tweak the JRuby runtimes per application context:
107
+
108
+ jruby_min_runtimes: 1
109
+ jruby_max_runtimes: 2
110
+
111
+
112
+ === Jetty Configuration
113
+
114
+ You can also modify the jetty per server configurations:
115
+
116
+ Thread pool will define the thread pool available to the jetty server using a QueuedThreadPool.
117
+
118
+ thread_pool_max: 40
119
+ thread_pool_min: 1
120
+
121
+
122
+ The acceptor size is the number of acceptor threads available for that server's channel connector.
123
+
124
+ acceptor_size: 20
125
+
126
+ See the jetty documentation for more information.
127
+
56
128
 
57
129
  == LICENSE:
58
130
 
@@ -0,0 +1,13 @@
1
+ == TODO never ends...
2
+
3
+ * Improve RDocs
4
+ * configuration defaults (web.xml, classes dir, lib dir, ...)
5
+ * integration test for lib_dir jars loading
6
+ * read configuration from warble.rb
7
+ * install custom resources from warbler configuration
8
+ * more command line options: --daemon, --num-instances
9
+ * add custom classes from warble.rb to the context classpath
10
+ * add custom jars from warble.rb to the context classpath
11
+ * load web.xml (or web.erb.xml) from config/web.xml
12
+ * read any custom jetty.xml
13
+ * support jetty-plus features (i.e.: jndi)
@@ -20,67 +20,21 @@
20
20
  # --environment ENV, -e ENV::
21
21
  # change rails environment (default: development)
22
22
  #
23
+ # --classes CLASSES_DIR::
24
+ # directory containing java classes used by the application (default: 'classes/')
25
+ #
26
+ # --lib LIB_DIR, --jars LIB_DIR::
27
+ # directory containing jars used by the application (default: 'lib/')
28
+ #
29
+ # --config FILE, -c FILE:: (optional)
30
+ # config file to use instead of command line switches (allows for multiple servers)
31
+ #
23
32
  # BASEDIR (optional): directory to be run (default: current).
24
33
 
25
34
  require "java"
35
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
26
36
  require "jetty_rails"
27
- require 'getoptlong'
28
- require 'rdoc/usage'
29
-
30
- # fix to work with rubygems (use current file instead of main)
31
- def RDoc.usage_no_exit(*args)
32
- comment = File.open(__FILE__) do |file|
33
- find_comment(file)
34
- end
35
-
36
- comment = comment.gsub(/^\s*#/, '')
37
-
38
- markup = SM::SimpleMarkup.new
39
- flow_convertor = SM::ToFlow.new
40
-
41
- flow = markup.convert(comment, flow_convertor)
42
-
43
- format = "plain"
44
-
45
- unless args.empty?
46
- flow = extract_sections(flow, args)
47
- end
48
-
49
- options = RI::Options.instance
50
- if args = ENV["RI"]
51
- options.parse(args.split)
52
- end
53
- formatter = options.formatter.new(options, "")
54
- formatter.display_flow(flow)
55
- end
56
-
57
- opts = GetoptLong.new(
58
- [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
59
- [ '--context-path', '-u', GetoptLong::REQUIRED_ARGUMENT ],
60
- [ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
61
- [ '--environment', '-e', GetoptLong::REQUIRED_ARGUMENT ]
62
- )
63
-
64
- config = {
65
- :base => Dir.pwd,
66
- :port => 4000,
67
- :adapter => :merb
68
- }
69
-
70
- opts.each do |opt, arg|
71
- case opt
72
- when '--help'
73
- RDoc::usage
74
- when '--context-path'
75
- config[:context_path] = arg
76
- when '--port'
77
- config[:port] = arg.to_i
78
- when '--environment'
79
- config[:environment] = arg
80
- end
81
- end
82
-
83
- config[:base] = ARGV.shift unless ARGV.empty?
84
37
 
85
- runner = JettyRails::Runner.new(config)
38
+ options = CommandLineReader.new.read(:merb)
39
+ runner = JettyRails::Runner.new(options)
86
40
  runner.start
@@ -20,67 +20,21 @@
20
20
  # --environment ENV, -e ENV::
21
21
  # change rails environment (default: development)
22
22
  #
23
+ # --classes CLASSES_DIR::
24
+ # directory containing java classes used by the application (default: 'classes/')
25
+ #
26
+ # --lib LIB_DIR, --jars LIB_DIR::
27
+ # directory containing jars used by the application (default: 'lib/')
28
+ #
29
+ # --config FILE, -c FILE:: (optional)
30
+ # config file to use instead of command line switches (allows for multiple servers)
31
+ #
23
32
  # BASEDIR (optional): directory to be run (default: current).
24
33
 
25
34
  require "java"
35
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
26
36
  require "jetty_rails"
27
- require 'getoptlong'
28
- require 'rdoc/usage'
29
-
30
- # fix to work with rubygems (use current file instead of main)
31
- def RDoc.usage_no_exit(*args)
32
- comment = File.open(__FILE__) do |file|
33
- find_comment(file)
34
- end
35
-
36
- comment = comment.gsub(/^\s*#/, '')
37
-
38
- markup = SM::SimpleMarkup.new
39
- flow_convertor = SM::ToFlow.new
40
-
41
- flow = markup.convert(comment, flow_convertor)
42
-
43
- format = "plain"
44
-
45
- unless args.empty?
46
- flow = extract_sections(flow, args)
47
- end
48
-
49
- options = RI::Options.instance
50
- if args = ENV["RI"]
51
- options.parse(args.split)
52
- end
53
- formatter = options.formatter.new(options, "")
54
- formatter.display_flow(flow)
55
- end
56
-
57
- opts = GetoptLong.new(
58
- [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
59
- [ '--context-path', '-u', GetoptLong::REQUIRED_ARGUMENT ],
60
- [ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
61
- [ '--environment', '-e', GetoptLong::REQUIRED_ARGUMENT ]
62
- )
63
-
64
- config = {
65
- :base => Dir.pwd,
66
- :port => 3000,
67
- :adapter => :rails
68
- }
69
-
70
- opts.each do |opt, arg|
71
- case opt
72
- when '--help'
73
- RDoc::usage
74
- when '--context-path'
75
- config[:context_path] = arg
76
- when '--port'
77
- config[:port] = arg.to_i
78
- when '--environment'
79
- config[:environment] = arg
80
- end
81
- end
82
-
83
- config[:base] = ARGV.shift unless ARGV.empty?
84
37
 
85
- runner = JettyRails::Runner.new(config)
38
+ options = CommandLineReader.new.read(:rails)
39
+ runner = JettyRails::Runner.new(options)
86
40
  runner.start
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
  include FileUtils
3
3
 
4
4
  require 'rubygems'
5
- %w[rake hoe newgem rubigen].each do |req_gem|
5
+ %w[rake hoe rubigen].each do |req_gem|
6
6
  begin
7
7
  require req_gem
8
8
  rescue LoadError
@@ -5,10 +5,15 @@ require "java"
5
5
  require "rubygems"
6
6
  require "activesupport"
7
7
  require "jetty_rails/jars"
8
+ require "jetty_rails/adapters/abstract_adapter"
8
9
  require "jetty_rails/adapters/rails_adapter"
9
10
  require "jetty_rails/adapters/merb_adapter"
10
11
  require "jetty_rails/runner"
12
+ require "jetty_rails/server"
11
13
  require "jetty_rails/handler/delegate_on_errors_handler"
14
+ require "jetty_rails/handler/public_directory_handler"
15
+ require "jetty_rails/handler/web_app_handler"
16
+ require "jetty_rails/config/command_line_reader"
12
17
 
13
18
  module JettyRails
14
19
  JETTY_RAILS_HOME = File.dirname(__FILE__) + "/.." unless defined?(JETTY_RAILS_HOME)
@@ -0,0 +1,25 @@
1
+ module JettyRails
2
+ module Adapters
3
+ class AbstractAdapter
4
+ attr_reader :config
5
+
6
+ def initialize(config)
7
+ @config = config
8
+ end
9
+
10
+ def base_init_params()
11
+ @base_init_params ||= {
12
+ 'public.root' => '/public',
13
+ 'gem.path' => config[:gem_path] || ENV['GEM_PATH'] || 'tmp/war/WEB-INF/gems',
14
+ 'jruby.initial.runtimes' => "#{config[:jruby_min_runtimes]}",
15
+ 'jruby.min.runtimes' => "#{config[:jruby_min_runtimes]}",
16
+ 'jruby.max.runtimes' => "#{config[:jruby_max_runtimes]}"
17
+ }
18
+ end
19
+
20
+ def event_listeners
21
+ []
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,21 +1,14 @@
1
1
  module JettyRails
2
2
  module Adapters
3
3
 
4
- class MerbAdapter
5
- attr_reader :config
6
-
7
- def initialize(config)
8
- @config = config
9
- end
4
+ class MerbAdapter < AbstractAdapter
10
5
 
11
6
  def init_params
12
7
  # please refer to goldspike and jruby-rack documentation
13
8
  @merb_params ||= {
14
9
  'merb.root' => '/',
15
- 'public.root' => '/public',
16
- 'merb.environment' => config[:environment],
17
- 'gem.path' => ENV['GEM_PATH'] || 'tmp/war/WEB-INF/gems'
18
- }
10
+ 'merb.environment' => config[:environment]
11
+ }.merge(base_init_params)
19
12
  end
20
13
 
21
14
  def event_listeners
@@ -1,21 +1,15 @@
1
1
  module JettyRails
2
2
  module Adapters
3
3
 
4
- class RailsAdapter
5
- attr_reader :config
6
-
7
- def initialize(config)
8
- @config = config
9
- end
10
-
4
+ class RailsAdapter < AbstractAdapter
5
+
11
6
  def init_params
12
7
  # please refer to goldspike and jruby-rack documentation
8
+ # in: PoolingRackApplicationFactory
13
9
  @rails_params ||= {
14
10
  'rails.root' => '/',
15
- 'public.root' => '/public',
16
- 'rails.env' => config[:environment],
17
- 'gem.path' => ENV['GEM_PATH'] || 'tmp/war/WEB-INF/gems'
18
- }
11
+ 'rails.env' => config[:environment]
12
+ }.merge(base_init_params)
19
13
  end
20
14
 
21
15
  def event_listeners