calavera-tomcat-rails 0.1.0
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.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/History.txt +4 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +56 -0
- data/TODO.txt +7 -0
- data/VERSION +1 -0
- data/bin/tomcat_rails +9 -0
- data/lib/tomcat-rails.rb +13 -0
- data/lib/tomcat-rails/jars.rb +26 -0
- data/lib/tomcat-rails/server.rb +75 -0
- data/test/test_helper.rb +11 -0
- data/test/tomcat-rails_test.rb +5 -0
- data/tomcat-libs/core-3.1.1.jar +0 -0
- data/tomcat-libs/jasper-el.jar +0 -0
- data/tomcat-libs/jasper-jdt.jar +0 -0
- data/tomcat-libs/jasper.jar +0 -0
- data/tomcat-libs/jetty-util-6.1.14.jar +0 -0
- data/tomcat-libs/jruby-rack-0.9.4.jar +0 -0
- data/tomcat-libs/jsp-2.1.jar +0 -0
- data/tomcat-libs/jsp-api-2.1.jar +0 -0
- data/tomcat-libs/servlet-api-2.5-6.1.14.jar +0 -0
- data/tomcat-libs/tomcat-core.jar +0 -0
- data/tomcat-libs/tomcat-dbcp.jar +0 -0
- data/tomcat-libs/tomcat-jasper.jar +0 -0
- metadata +80 -0
data/.document
ADDED
data/History.txt
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 David Calavera
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= tomcat-rails
|
2
|
+
|
3
|
+
Tomcat Rails allows you to run a rails application within a Tomcat container.
|
4
|
+
|
5
|
+
This project has just born, there are a lot of things to do. Take a look at the TODO.txt file and feel free to add new features, tests, patches...
|
6
|
+
|
7
|
+
== INSTALL:
|
8
|
+
|
9
|
+
jgem install calavera-tomcat-rails -s http://gems.github.com
|
10
|
+
|
11
|
+
== USAGE:
|
12
|
+
|
13
|
+
cd myrailsapp
|
14
|
+
jruby -S tomcat_rails
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 David Calavera<calavera@apache.org>. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "tomcat-rails"
|
8
|
+
gem.summary = %Q{Simple library to run a rails application into an embed Tomcat}
|
9
|
+
gem.email = "david.calavera@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/calavera/tomcat-rails"
|
11
|
+
gem.authors = ["David Calavera"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |test|
|
21
|
+
test.libs << 'lib' << 'test'
|
22
|
+
test.pattern = 'test/**/*_test.rb'
|
23
|
+
test.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'rcov/rcovtask'
|
28
|
+
Rcov::RcovTask.new do |test|
|
29
|
+
test.libs << 'test'
|
30
|
+
test.pattern = 'test/**/*_test.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
task :rcov do
|
35
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
if File.exist?('VERSION.yml')
|
45
|
+
config = YAML.load(File.read('VERSION.yml'))
|
46
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "tomcat-rails #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
|
data/TODO.txt
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/tomcat_rails
ADDED
data/lib/tomcat-rails.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require "java"
|
5
|
+
require 'rubygems'
|
6
|
+
|
7
|
+
require 'tomcat-rails/command_line_parser'
|
8
|
+
require 'tomcat-rails/jars'
|
9
|
+
require 'tomcat-rails/server'
|
10
|
+
|
11
|
+
module TomcatRails
|
12
|
+
TOMCAT_LIBS = File.dirname(__FILE__) + "/../tomcat-libs" unless defined?(TOMCAT_LIBS)
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module TomcatRails
|
2
|
+
|
3
|
+
require "servlet-api-2.5-6.1.14"
|
4
|
+
require "core-3.1.1"
|
5
|
+
require "jsp-api-2.1"
|
6
|
+
require "jsp-2.1"
|
7
|
+
require 'tomcat-core'
|
8
|
+
require 'jetty-util-6.1.14'
|
9
|
+
|
10
|
+
require "jruby-rack-0.9.4"
|
11
|
+
|
12
|
+
module Tomcat
|
13
|
+
include_package 'org.apache.catalina'
|
14
|
+
include_package 'org.apache.catalina.startup'
|
15
|
+
include_package 'org.apache.catalina.core'
|
16
|
+
include_package 'org.apache.catalina.deploy'
|
17
|
+
include_package 'org.apache.catalina.loader'
|
18
|
+
|
19
|
+
include_package 'org.apache.naming.resources'
|
20
|
+
end
|
21
|
+
|
22
|
+
module Rack
|
23
|
+
include_package "org.jruby.rack"
|
24
|
+
include_package "org.jruby.rack.rails"
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module TomcatRails
|
2
|
+
class Server
|
3
|
+
|
4
|
+
@@defaults = {
|
5
|
+
:environment => 'development',
|
6
|
+
:context_path => '/',
|
7
|
+
:lib_dir => 'lib',
|
8
|
+
:classes_dir => 'classes',
|
9
|
+
:port => 3000,
|
10
|
+
:jruby_min_runtimes => 1,
|
11
|
+
:jruby_max_runtimes => 5
|
12
|
+
}
|
13
|
+
|
14
|
+
def initialize(config = {})
|
15
|
+
@config = config.merge!(@@defaults)
|
16
|
+
|
17
|
+
@tomcat = TomcatRails::Tomcat::Tomcat.new
|
18
|
+
@tomcat.setPort(@config[:port])
|
19
|
+
|
20
|
+
web_app = @tomcat.addWebapp(@config[:context_path], Dir.pwd)
|
21
|
+
|
22
|
+
add_rack_filter(web_app, @config[:context_path])
|
23
|
+
add_context_loader(web_app)
|
24
|
+
add_init_params(web_app)
|
25
|
+
add_web_dir_resources(web_app)
|
26
|
+
|
27
|
+
web_app.addApplicationListener('org.jruby.rack.rails.RailsServletContextListener')
|
28
|
+
end
|
29
|
+
|
30
|
+
def start
|
31
|
+
@tomcat.start
|
32
|
+
@tomcat.getServer().await
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def add_rack_filter(web_app, context_path)
|
37
|
+
filter_def = TomcatRails::Tomcat::FilterDef.new
|
38
|
+
filter_def.setFilterName('RackFilter')
|
39
|
+
filter_def.setFilterClass('org.jruby.rack.RackFilter')
|
40
|
+
|
41
|
+
pattern = context_path[-1..-1] != '/' ? context_path : context_path[0..-2]
|
42
|
+
filter_map = TomcatRails::Tomcat::FilterMap.new
|
43
|
+
filter_map.setFilterName('RackFilter')
|
44
|
+
filter_map.addURLPattern("#{pattern}/*")
|
45
|
+
|
46
|
+
web_app.addFilterDef(filter_def)
|
47
|
+
web_app.addFilterMap(filter_map)
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_context_loader(web_app)
|
51
|
+
class_loader = org.jruby.util.JRubyClassLoader.new(JRuby.runtime.jruby_class_loader)
|
52
|
+
loader = TomcatRails::Tomcat::WebappLoader.new(class_loader)
|
53
|
+
|
54
|
+
loader.container = web_app
|
55
|
+
web_app.loader = loader
|
56
|
+
end
|
57
|
+
|
58
|
+
def add_init_params(web_app)
|
59
|
+
[:jruby_min_runtimes, :jruby_max_runtimes].each do |param|
|
60
|
+
web_app.addParameter(param.to_s.gsub(/_/, '.'), @config[param].to_s)
|
61
|
+
end
|
62
|
+
|
63
|
+
web_app.addParameter('jruby.initial.runtimes', @config[:jruby_min_runtimes].to_s)
|
64
|
+
web_app.addParameter('rails.env', @config[:environment].to_s)
|
65
|
+
web_app.addParameter('rails.root', '/')
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_web_dir_resources(web_app)
|
69
|
+
dir_context = TomcatRails::Tomcat::FileDirContext.new
|
70
|
+
dir_context.setDocBase(File.join(Dir.pwd, "public"))
|
71
|
+
|
72
|
+
web_app.setResources(dir_context)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/test/test_helper.rb
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: calavera-tomcat-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Calavera
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-11 00:00:00 -07:00
|
13
|
+
default_executable: tomcat_rails
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: david.calavera@gmail.com
|
18
|
+
executables:
|
19
|
+
- tomcat_rails
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .document
|
27
|
+
- .gitignore
|
28
|
+
- History.txt
|
29
|
+
- LICENSE
|
30
|
+
- README.rdoc
|
31
|
+
- Rakefile
|
32
|
+
- TODO.txt
|
33
|
+
- VERSION
|
34
|
+
- bin/tomcat_rails
|
35
|
+
- lib/tomcat-rails.rb
|
36
|
+
- lib/tomcat-rails/jars.rb
|
37
|
+
- lib/tomcat-rails/server.rb
|
38
|
+
- test/test_helper.rb
|
39
|
+
- test/tomcat-rails_test.rb
|
40
|
+
- tomcat-libs/core-3.1.1.jar
|
41
|
+
- tomcat-libs/jasper-el.jar
|
42
|
+
- tomcat-libs/jasper-jdt.jar
|
43
|
+
- tomcat-libs/jasper.jar
|
44
|
+
- tomcat-libs/jetty-util-6.1.14.jar
|
45
|
+
- tomcat-libs/jruby-rack-0.9.4.jar
|
46
|
+
- tomcat-libs/jsp-2.1.jar
|
47
|
+
- tomcat-libs/jsp-api-2.1.jar
|
48
|
+
- tomcat-libs/servlet-api-2.5-6.1.14.jar
|
49
|
+
- tomcat-libs/tomcat-core.jar
|
50
|
+
- tomcat-libs/tomcat-dbcp.jar
|
51
|
+
- tomcat-libs/tomcat-jasper.jar
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://github.com/calavera/tomcat-rails
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --charset=UTF-8
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.2.0
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Simple library to run a rails application into an embed Tomcat
|
78
|
+
test_files:
|
79
|
+
- test/test_helper.rb
|
80
|
+
- test/tomcat-rails_test.rb
|