mikewadhera-jetty-rails 0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/History.txt +45 -0
  2. data/Licenses.txt +37 -0
  3. data/Manifest.txt +52 -0
  4. data/PostInstall.txt +2 -0
  5. data/README.txt +140 -0
  6. data/Rakefile +4 -0
  7. data/TODO.txt +11 -0
  8. data/bin/jetty_merb +41 -0
  9. data/bin/jetty_rails +41 -0
  10. data/config/hoe.rb +76 -0
  11. data/config/requirements.rb +16 -0
  12. data/jetty-libs/core-3.1.1.jar +0 -0
  13. data/jetty-libs/jetty-6.1.14.jar +0 -0
  14. data/jetty-libs/jetty-plus-6.1.14.jar +0 -0
  15. data/jetty-libs/jetty-util-6.1.14.jar +0 -0
  16. data/jetty-libs/jsp-2.1.jar +0 -0
  17. data/jetty-libs/jsp-api-2.1.jar +0 -0
  18. data/jetty-libs/servlet-api-2.5-6.1.14.jar +0 -0
  19. data/lib/jetty_rails/adapters/abstract_adapter.rb +25 -0
  20. data/lib/jetty_rails/adapters/merb_adapter.rb +34 -0
  21. data/lib/jetty_rails/adapters/rails_adapter.rb +22 -0
  22. data/lib/jetty_rails/config/command_line_reader.rb +73 -0
  23. data/lib/jetty_rails/config/rdoc_fix.rb +28 -0
  24. data/lib/jetty_rails/handler/delegate_on_errors_handler.rb +29 -0
  25. data/lib/jetty_rails/handler/public_directory_handler.rb +24 -0
  26. data/lib/jetty_rails/handler/web_app_handler.rb +85 -0
  27. data/lib/jetty_rails/jars.rb +37 -0
  28. data/lib/jetty_rails/runner.rb +46 -0
  29. data/lib/jetty_rails/server.rb +76 -0
  30. data/lib/jetty_rails/version.rb +8 -0
  31. data/lib/jetty_rails/warbler_reader.rb +13 -0
  32. data/lib/jetty_rails.rb +21 -0
  33. data/lib/jruby-rack-0.9.4.jar +0 -0
  34. data/script/console +10 -0
  35. data/script/destroy +14 -0
  36. data/script/generate +14 -0
  37. data/script/txt2html +82 -0
  38. data/setup.rb +1585 -0
  39. data/spec/config.yml +28 -0
  40. data/spec/jetty_merb_spec.rb +195 -0
  41. data/spec/jetty_rails/config_file_spec.rb +68 -0
  42. data/spec/jetty_rails/handler/delegate_on_errors_handler_spec.rb +29 -0
  43. data/spec/jetty_rails/runner_spec.rb +162 -0
  44. data/spec/jetty_rails_sample_1.yml +13 -0
  45. data/spec/jetty_rails_sample_2.yml +28 -0
  46. data/spec/jetty_rails_spec.rb +195 -0
  47. data/spec/spec.opts +2 -0
  48. data/spec/spec_helper.rb +12 -0
  49. data/tasks/deployment.rake +39 -0
  50. data/tasks/environment.rake +7 -0
  51. data/tasks/rspec.rake +43 -0
  52. data/tasks/website.rake +17 -0
  53. metadata +138 -0
data/History.txt ADDED
@@ -0,0 +1,45 @@
1
+ == 0.8
2
+ * reading config/web.xml file (not yet supporting config/web.xml.erb)
3
+ * supporting /public/WEB-INF dir for custom web resources (config files and taglibs)
4
+
5
+ == 0.7
6
+ * Merb 1.0 support!
7
+ * jruby-rack updated to the latest release (0.9.3)
8
+ * jetty server update to 6.1.14
9
+ * adding known issue with jruby-1.1.4 to the docs
10
+ * JSP and JSP Expression Language support
11
+ * some minor bugs
12
+
13
+ == 0.6
14
+ * load all java classes inside classes/ by default
15
+ * command line args to customize lib/ and classes/ directories
16
+ * -v showing jetty_rails version
17
+ * each web application context has its own classloader (isolated classpaths)
18
+ * upgraded to jruby-rack-0.9.2 (no more views being cached in development time)
19
+ * minor changes and refactorings
20
+ * improved docs for multi-server support
21
+
22
+ == 0.5
23
+ * load all jars inside lib/ by default
24
+ * using GEM_PATH environment variable, if exists
25
+ * fix signal handling (ctrl + c) for jetty_merb
26
+
27
+ == 0.4
28
+ * Merb support! jruby -S jetty_merb
29
+ * Changed default ports to 3000 (rails) and 4000 (merb)
30
+ * More specs
31
+
32
+ == 0.3
33
+
34
+ * Improved Documentation: rdoc and site.
35
+
36
+ == 0.2
37
+
38
+ * Running any rails applications with no extra classpath.
39
+ * Command line options for jett_rails binary executable.
40
+ See: <tt>jruby -S jetty_rails --help</tt> for details.
41
+
42
+ == 0.1
43
+
44
+ * Initial release.
45
+ * Running default rails applications inside Jetty.
data/Licenses.txt ADDED
@@ -0,0 +1,37 @@
1
+ = Jetty Rails
2
+
3
+ Jetty Rails is distributed under the terms of the MIT License.
4
+
5
+ Copyright (c) 2008 Fabio Kung
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+
26
+ = Additional Bundled Software
27
+
28
+ JRuby-Rack (jruby-rack-*.jar) is distributed under the terms of the
29
+ MIT license. See http://svn.codehaus.org/jruby-contrib/trunk/rack/LICENSE.txt
30
+ for details.
31
+
32
+ Jetty (jetty-*.jar) is distributed under the terms of the Apache 2.0 License.
33
+ See http://jetty.mortbay.org/jetty-6/LICENSE.txt for details.
34
+
35
+ Servlet API 2.5, a.k.a JSR-154, (servlet-api-2.5-*.jar) is distributed
36
+ under the terms of the Berkeley License. See http://developers.sun.com/license/berkeley_license.html
37
+ for details.
data/Manifest.txt ADDED
@@ -0,0 +1,52 @@
1
+ History.txt
2
+ Licenses.txt
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.txt
6
+ Rakefile
7
+ TODO.txt
8
+ bin/jetty_merb
9
+ bin/jetty_rails
10
+ config/hoe.rb
11
+ config/requirements.rb
12
+ jetty-libs/core-3.1.1.jar
13
+ jetty-libs/jetty-6.1.14.jar
14
+ jetty-libs/jetty-plus-6.1.14.jar
15
+ jetty-libs/jetty-util-6.1.14.jar
16
+ jetty-libs/jsp-2.1.jar
17
+ jetty-libs/jsp-api-2.1.jar
18
+ jetty-libs/servlet-api-2.5-6.1.14.jar
19
+ lib/jetty_rails.rb
20
+ lib/jetty_rails/adapters/abstract_adapter.rb
21
+ lib/jetty_rails/adapters/merb_adapter.rb
22
+ lib/jetty_rails/adapters/rails_adapter.rb
23
+ lib/jetty_rails/config/command_line_reader.rb
24
+ lib/jetty_rails/config/rdoc_fix.rb
25
+ lib/jetty_rails/handler/delegate_on_errors_handler.rb
26
+ lib/jetty_rails/handler/public_directory_handler.rb
27
+ lib/jetty_rails/handler/web_app_handler.rb
28
+ lib/jetty_rails/jars.rb
29
+ lib/jetty_rails/runner.rb
30
+ lib/jetty_rails/server.rb
31
+ lib/jetty_rails/version.rb
32
+ lib/jetty_rails/warbler_reader.rb
33
+ lib/jruby-rack-0.9.4.jar
34
+ script/console
35
+ script/destroy
36
+ script/generate
37
+ script/txt2html
38
+ setup.rb
39
+ spec/config.yml
40
+ spec/jetty_merb_spec.rb
41
+ spec/jetty_rails/config_file_spec.rb
42
+ spec/jetty_rails/handler/delegate_on_errors_handler_spec.rb
43
+ spec/jetty_rails/runner_spec.rb
44
+ spec/jetty_rails_sample_1.yml
45
+ spec/jetty_rails_sample_2.yml
46
+ spec/jetty_rails_spec.rb
47
+ spec/spec.opts
48
+ spec/spec_helper.rb
49
+ tasks/deployment.rake
50
+ tasks/environment.rake
51
+ tasks/rspec.rake
52
+ tasks/website.rake
data/PostInstall.txt ADDED
@@ -0,0 +1,2 @@
1
+
2
+ For more information on jetty-rails, see http://jetty-rails.rubyforge.org
data/README.txt ADDED
@@ -0,0 +1,140 @@
1
+ = jetty-rails
2
+
3
+ http://jetty-rails.rubyforge.net
4
+
5
+ == DESCRIPTION:
6
+
7
+ Jetty Rails aims to run Ruby on Rails and Merb applications with the Jetty Container, leveraging the power of JRuby and jruby-rack.
8
+
9
+ {Jetty}[http://jetty.mortbay.com/jetty/] is an excellent Java Web Server, being and at the same time extremely lightweight. This makes jetty-rails a good alternative for JRuby on Rails or Merb development and deployment.
10
+
11
+ The project has born from my own needs ({read more}[http://fabiokung.com/2008/05/14/jetty-rails-gem-simple-jruby-on-rails-development-with-servlet-containers/]). I needed to run {JForum}[http://jforum.net] in the same context of my JRuby on Rails application. I had also to integrate HttpSessions (avoiding single sign on) and use ServletContext in-memory cache store.
12
+
13
+ == FEATURES:
14
+
15
+ * Uses {JRuby Rack}[http://wiki.jruby.org/wiki/JRuby_Rack].
16
+ * Loads all jars inside your application lib/ dir, by default.
17
+ * Loads all classes inside your application classes/ dir, by default.
18
+ * Supports rails and merb applications out of the box.
19
+
20
+ == KNOWN ISSUES
21
+
22
+ * Doesn't work with gems inside $HOME/.gem, because jruby-rack overwrites custom gem paths. Please install jruby in writable places, or install your gems with sudo <tt>jruby -S gem install NAME</tt>.
23
+
24
+ * Doesn't work with JRuby 1.1.4: http://jira.codehaus.org/browse/JRUBY-2959
25
+
26
+ * To generate coverage report with jruby (>= 1.1) follow instructions from http://www.ruby-forum.com/topic/146252 and run (inside jetty-rails root dir):
27
+ jruby -S rake rcov
28
+
29
+ * Hoe in jruby has an issue reading the ~/.hoerc file. Just remove it.
30
+
31
+ == USAGE:
32
+
33
+ === Rails:
34
+
35
+ cd myrailsapp
36
+ jruby -S jetty_rails
37
+
38
+ help option shows usage details:
39
+
40
+ jruby -S jetty_rails --help
41
+
42
+ === Merb:
43
+
44
+ cd mymerbapp
45
+ jruby -S jetty_merb
46
+
47
+ help option shows usage details:
48
+
49
+ jruby -S jetty_merb --help
50
+
51
+ === Merb:
52
+
53
+ cd mymerbapp
54
+ jruby -S jetty_merb
55
+
56
+ help option shows usage details:
57
+
58
+ jruby -S jetty_merb --help
59
+
60
+
61
+ == REQUIREMENTS:
62
+
63
+ jetty-rails requires jruby (>=1.1). Please make sure you already have
64
+ it properly installed and inserted in your PATH environment variable.
65
+
66
+ {Installing JRuby Instructions}[http://wiki.jruby.org/wiki/Getting_Started]
67
+
68
+ == INSTALL:
69
+
70
+ jruby -S gem install jetty-rails
71
+
72
+ == BUGS AND NEW FEATURES
73
+
74
+ Using Lighthouse: http://fabiokung.lighthouseapp.com/projects/12666-jetty-rails
75
+
76
+
77
+ == MULTIPLE SERVERS:
78
+
79
+ You can specify a configuration yaml file rather than command line switches.
80
+ The file also allows specifying multiple servers and / or application contexts for single jetty container.
81
+
82
+ For example, you could set a context_path of /testA on port 8888 which is rails, /testB also that port which is merb.
83
+ Or, you could have /testA on port 8888 and /testB on port 9999.
84
+
85
+ jruby -S jetty_rails -c path/to/config.yml
86
+
87
+ The configuration options are inherited, so if you specify the environment to be "production" at the top level,
88
+ then any servers and application context will be "production" unless the choose to override the value.
89
+
90
+ - server settings:
91
+ <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>
92
+
93
+ - application context settings:
94
+ <tt>:context_path</tt>, <tt>:base</tt>, <tt>:adapter</tt>, <tt>:environment</tt>, <tt>:lib_dir</tt>, <tt>:gem_path</tt>
95
+
96
+ As part of the configuration you have some control over jruby & jetty.
97
+
98
+ See spec/config.yml, spec/jetty_rails_sample_1.yml, and spec/jetty_rails_sample_2.yml for more examples.
99
+
100
+ === Rails:
101
+
102
+ If -c is not specified, by default jetty_rails will look for a config/jetty_rails.yml relative to where it is started.
103
+
104
+ Don't forget to add this into your config/environment.rb
105
+ ActionController::AbstractRequest.relative_url_root = "/testA"
106
+
107
+
108
+ === JRuby Configuration
109
+
110
+ You can tweak the JRuby runtimes per application context:
111
+
112
+ jruby_min_runtimes: 1
113
+ jruby_max_runtimes: 2
114
+
115
+
116
+ === Jetty Configuration
117
+
118
+ You can also modify the jetty per server configurations:
119
+
120
+ Thread pool will define the thread pool available to the jetty server using a QueuedThreadPool.
121
+
122
+ thread_pool_max: 40
123
+ thread_pool_min: 1
124
+
125
+
126
+ The acceptor size is the number of acceptor threads available for that server's channel connector.
127
+
128
+ acceptor_size: 20
129
+
130
+ See the jetty documentation for more information.
131
+
132
+
133
+ == LICENSE:
134
+
135
+ Jetty Rails is distributed under the terms of The MIT License.
136
+ Copyright (c) 2008 Fabio Kung <fabio.kung@gmail.com>
137
+
138
+ Read more details in the bundled +Licenses.txt+ file. There are other
139
+ pieces of software bundled with jetty-rails. Before using jetty-rails,
140
+ make sure you agree with all of them.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/TODO.txt ADDED
@@ -0,0 +1,11 @@
1
+ == TODO never ends...
2
+
3
+ * Improve RDocs
4
+ * integration test for lib_dir jars loading
5
+ * read configuration from warble.rb
6
+ * install custom resources from warbler configuration
7
+ * add custom classes from warble.rb to the context classpath
8
+ * add custom jars from warble.rb to the context classpath
9
+ * support config/web.xml.erb
10
+ * read any custom jetty.xml
11
+ * support jetty-plus features (i.e.: jndi)
data/bin/jetty_merb ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env jruby
2
+
3
+ # == Synopsis
4
+ #
5
+ # jetty_merb: jetty server for merb applications
6
+ #
7
+ # == Usage
8
+ #
9
+ # jetty_merb [OPTION] ... BASEDIR
10
+ #
11
+ # -h, --help::
12
+ # show help
13
+ #
14
+ # --context-path PATH, -u PATH::
15
+ # change the application context path (default: '/')
16
+ #
17
+ # --port PORT, -p PORT::
18
+ # change server port (default: 4000)
19
+ #
20
+ # --environment ENV, -e ENV::
21
+ # change rails environment (default: development)
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
+ #
32
+ # BASEDIR (optional): directory to be run (default: current).
33
+
34
+ require "java"
35
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
36
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/../jetty-libs"
37
+ require "jetty_rails"
38
+
39
+ options = CommandLineReader.new.read(:merb)
40
+ runner = JettyRails::Runner.new(options)
41
+ runner.start
data/bin/jetty_rails ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env jruby
2
+
3
+ # == Synopsis
4
+ #
5
+ # jetty_rails: jetty server for rails applications
6
+ #
7
+ # == Usage
8
+ #
9
+ # jetty_rails [OPTION] ... BASEDIR
10
+ #
11
+ # -h, --help::
12
+ # show help
13
+ #
14
+ # --context-path PATH, -u PATH::
15
+ # change the application context path (default: '/')
16
+ #
17
+ # --port PORT, -p PORT::
18
+ # change server port (default: 3000)
19
+ #
20
+ # --environment ENV, -e ENV::
21
+ # change rails environment (default: development)
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
+ #
32
+ # BASEDIR (optional): directory to be run (default: current).
33
+
34
+ require "java"
35
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
36
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/../jetty-libs"
37
+ require "jetty_rails"
38
+
39
+ options = CommandLineReader.new.read(:rails)
40
+ runner = JettyRails::Runner.new(options)
41
+ runner.start
data/config/hoe.rb ADDED
@@ -0,0 +1,76 @@
1
+ require 'jetty_rails/version'
2
+
3
+ AUTHOR = 'Fabio Kung' # can also be an array of Authors
4
+ EMAIL = "fabio.kung@gmail.com"
5
+ DESCRIPTION = "jetty server for rails applications"
6
+ GEM_NAME = 'jetty-rails' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'jetty-rails' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ ['activesupport', '>= 1.3.1']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "unknown"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ REV = nil
35
+ # UNCOMMENT IF REQUIRED:
36
+ # REV = YAML.load(`svn info`)['Revision']
37
+ VERS = JettyRails::VERSION::STRING + (REV ? ".#{REV}" : "")
38
+ RDOC_OPTS = ['--quiet', '--title', 'jetty-rails documentation',
39
+ "--opname", "index.html",
40
+ "--line-numbers",
41
+ "--main", "README",
42
+ "--exclude", "*.jar",
43
+ "--inline-source"]
44
+
45
+ class Hoe
46
+ def extra_deps
47
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
48
+ @extra_deps
49
+ end
50
+ end
51
+
52
+ # Generate all the Rake tasks
53
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
54
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
55
+ p.developer(AUTHOR, EMAIL)
56
+ p.description = DESCRIPTION
57
+ p.summary = DESCRIPTION
58
+ p.url = HOMEPATH
59
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
60
+ p.test_globs = ["spec/**/*_spec.rb"]
61
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
62
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
63
+ p.extra_deps = EXTRA_DEPENDENCIES
64
+ p.rdoc_pattern = /^(lib|bin|ext).*[^\.jar]$|txt$/
65
+
66
+ # A hash of extra values to set in the gemspec.
67
+ # p.spec_extras = {
68
+ # :platform => "java"
69
+ # }
70
+ end
71
+
72
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
73
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
74
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
75
+ $hoe.rsync_args = '-av --delete --ignore-errors'
76
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -0,0 +1,16 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ gem 'hoe', '<= 1.8.2'
6
+ %w[rake hoe rubigen].each do |req_gem|
7
+ begin
8
+ require req_gem
9
+ rescue LoadError
10
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
11
+ puts "Installation: gem install #{req_gem} -y"
12
+ exit
13
+ end
14
+ end
15
+
16
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -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
@@ -0,0 +1,34 @@
1
+ module JettyRails
2
+ module Adapters
3
+
4
+ class MerbAdapter < AbstractAdapter
5
+
6
+ def init_params
7
+ # please refer to goldspike and jruby-rack documentation
8
+ @merb_params ||= {
9
+ 'merb.root' => '/',
10
+ 'merb.environment' => config[:environment]
11
+ }.merge(base_init_params)
12
+ end
13
+
14
+ def event_listeners
15
+ [ Rack::MerbServletContextListener.new, SignalHandler.new ]
16
+ end
17
+
18
+ class SignalHandler
19
+ include Java::JavaxServlet::ServletContextListener
20
+
21
+ def contextInitialized(cfg)
22
+ trap("INT") do
23
+ puts "\nbye!"
24
+ java.lang.System.exit(0)
25
+ end
26
+ end
27
+
28
+ def contextDestroyed(cfg)
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,22 @@
1
+ module JettyRails
2
+ module Adapters
3
+
4
+ class RailsAdapter < AbstractAdapter
5
+
6
+ def init_params
7
+ # please refer to goldspike and jruby-rack documentation
8
+ # in: PoolingRackApplicationFactory
9
+ @rails_params ||= {
10
+ 'rails.root' => '/',
11
+ 'rails.env' => config[:environment]
12
+ }.merge(base_init_params)
13
+ end
14
+
15
+ def event_listeners
16
+ [ Rack::RailsServletContextListener.new ]
17
+ end
18
+
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,73 @@
1
+ require 'getoptlong'
2
+ require 'jetty_rails/config/rdoc_fix'
3
+
4
+
5
+ class CommandLineReader
6
+
7
+ def default_config()
8
+ @@config ||= {
9
+ :rails => {
10
+ :base => Dir.pwd,
11
+ :port => 3000,
12
+ :config_file => "#{File.join(Dir.pwd, 'config', 'jetty_rails.yml')}",
13
+ :adapter => :rails
14
+ },
15
+ :merb => {
16
+ :base => Dir.pwd,
17
+ :port => 4000,
18
+ :config_file => "#{File.join(Dir.pwd, 'config', 'jetty_merb.yml')}",
19
+ :adapter => :merb
20
+ }
21
+ }
22
+ end
23
+
24
+ def read(default_adapter = :rails)
25
+ config = default_config[default_adapter]
26
+
27
+ opts = GetoptLong.new(
28
+ [ '--version', '-v', GetoptLong::NO_ARGUMENT ],
29
+ [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
30
+ [ '--context-path', '-u', GetoptLong::REQUIRED_ARGUMENT ],
31
+ [ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
32
+ [ '--environment', '-e', GetoptLong::REQUIRED_ARGUMENT ],
33
+ [ '--lib', '--jars', GetoptLong::REQUIRED_ARGUMENT ],
34
+ [ '--classes', GetoptLong::REQUIRED_ARGUMENT ],
35
+ [ '--config', '-c', GetoptLong::OPTIONAL_ARGUMENT ]
36
+ )
37
+
38
+ opts.each do |opt, arg|
39
+ case opt
40
+ when '--version'
41
+ require 'jetty_rails/version'
42
+ puts "JettyRails version #{JettyRails::VERSION::STRING} - http://jetty-rails.rubyforge.org"
43
+ exit(0)
44
+ when '--help'
45
+ RDoc::usage
46
+ when '--context-path'
47
+ config[:context_path] = arg
48
+ when '--port'
49
+ config[:port] = arg.to_i
50
+ when '--environment'
51
+ config[:environment] = arg
52
+ when '--classes'
53
+ config[:classes_dir] = arg
54
+ when '--lib'
55
+ config[:lib_dir] = arg
56
+ when '--config'
57
+ config[:config_file] = arg if !arg.nil? && arg != ""
58
+ end
59
+ end
60
+
61
+ config[:base] = ARGV.shift unless ARGV.empty?
62
+
63
+ if File.exists?(config[:config_file])
64
+ config.merge!(YAML.load_file(config[:config_file]))
65
+ puts "Loaded #{config[:config_file]}"
66
+ end
67
+
68
+ config
69
+ end
70
+
71
+ end
72
+
73
+
@@ -0,0 +1,28 @@
1
+ require 'rdoc/usage'
2
+
3
+ # fix to work with rubygems (use current file instead of main)
4
+ def RDoc.usage_no_exit(*args)
5
+ comment = File.open(File.join(File.dirname(__FILE__), %w(.. .. .. bin), File.basename($0))) do |file|
6
+ find_comment(file)
7
+ end
8
+
9
+ comment = comment.gsub(/^\s*#/, '')
10
+
11
+ markup = SM::SimpleMarkup.new
12
+ flow_convertor = SM::ToFlow.new
13
+
14
+ flow = markup.convert(comment, flow_convertor)
15
+
16
+ format = "plain"
17
+
18
+ unless args.empty?
19
+ flow = extract_sections(flow, args)
20
+ end
21
+
22
+ options = RI::Options.instance
23
+ if args = ENV["RI"]
24
+ options.parse(args.split)
25
+ end
26
+ formatter = options.formatter.new(options, "")
27
+ formatter.display_flow(flow)
28
+ end