trinidad 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -0
- data/VERSION +1 -1
- data/lib/trinidad/core_ext.rb +0 -14
- data/lib/trinidad/rackup_web_app.rb +1 -1
- data/lib/trinidad/rails_web_app.rb +2 -2
- data/lib/trinidad/server.rb +39 -57
- data/lib/trinidad/web_app.rb +9 -4
- data/spec/trinidad/server_spec.rb +12 -12
- data/spec/trinidad/web_app_spec.rb +3 -3
- metadata +75 -55
data/Rakefile
CHANGED
@@ -14,6 +14,9 @@ begin
|
|
14
14
|
gem.files = FileList['bin/*', 'lib/**/*.rb', 'trinidad-libs/*.jar', 'History.txt', 'LICENSE', 'Rakefile', 'README.rdoc', 'VERSION']
|
15
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
16
|
gem.add_dependency 'rack', '>=1.0'
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rspec'
|
19
|
+
gem.add_development_dependency 'mocha'
|
17
20
|
end
|
18
21
|
|
19
22
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
data/lib/trinidad/core_ext.rb
CHANGED
@@ -3,8 +3,8 @@ module Trinidad
|
|
3
3
|
|
4
4
|
def add_init_params
|
5
5
|
super
|
6
|
-
|
7
|
-
|
6
|
+
add_parameter_unless_exist('rails.env', environment.to_s)
|
7
|
+
add_parameter_unless_exist('rails.root', '/')
|
8
8
|
end
|
9
9
|
|
10
10
|
def context_listener
|
data/lib/trinidad/server.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Trinidad
|
2
2
|
class Server
|
3
|
-
|
3
|
+
|
4
4
|
attr_reader :tomcat
|
5
|
-
|
5
|
+
|
6
6
|
def default_options
|
7
7
|
{
|
8
8
|
:environment => 'development',
|
@@ -15,38 +15,33 @@ module Trinidad
|
|
15
15
|
:jruby_max_runtimes => 5
|
16
16
|
}
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def initialize(config = {})
|
20
20
|
load_config(config)
|
21
21
|
load_tomcat_server
|
22
22
|
create_web_apps
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def load_config(config)
|
26
26
|
@config = default_options.deep_merge(config)
|
27
27
|
add_default_web_app!(@config)
|
28
|
-
|
29
|
-
configure_ssl!(@config)
|
30
28
|
end
|
31
|
-
|
29
|
+
|
32
30
|
def load_tomcat_server
|
33
31
|
@tomcat = Trinidad::Tomcat::Tomcat.new
|
34
32
|
@tomcat.setPort(@config[:port].to_i)
|
35
33
|
@tomcat.setBaseDir(Dir.pwd)
|
36
|
-
|
34
|
+
|
37
35
|
add_ssl_connector if ssl_enabled?
|
38
36
|
add_ajp_connector if ajp_enabled?
|
39
37
|
end
|
40
|
-
|
38
|
+
|
41
39
|
def create_web_apps
|
42
40
|
@config[:web_apps].each do |name, app|
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
app[:web_app_dir] = Dir.pwd unless app.has_key?(:web_app_dir)
|
41
|
+
app[:context_path] ||= (name.to_s == 'default' ? '/' : "/#{name.to_s}")
|
42
|
+
app[:web_app_dir] ||= Dir.pwd
|
47
43
|
|
48
44
|
tomcat_app = @tomcat.addWebapp(app[:context_path].to_s, app[:web_app_dir])
|
49
|
-
# tomcat_app.setDocBase(app[:web_app_dir])
|
50
45
|
|
51
46
|
web_app = WebApp.create(tomcat_app, @config, app)
|
52
47
|
|
@@ -55,60 +50,60 @@ module Trinidad
|
|
55
50
|
web_app.add_context_loader
|
56
51
|
web_app.add_init_params
|
57
52
|
web_app.add_web_dir_resources
|
58
|
-
|
53
|
+
|
59
54
|
web_app.add_rack_context_listener
|
60
55
|
end
|
61
56
|
end
|
62
|
-
|
57
|
+
|
63
58
|
def add_service_connector(options, protocol = nil)
|
64
59
|
connector = Trinidad::Tomcat::Connector.new(protocol)
|
65
60
|
|
66
61
|
opts = options.dup
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
62
|
+
|
63
|
+
connector.scheme = opts.delete(:scheme) if opts[:scheme]
|
64
|
+
connector.secure = opts.delete(:secure) || false
|
65
|
+
connector.port = opts.delete(:port).to_i
|
66
|
+
|
67
|
+
options.each do |key, value|
|
68
|
+
connector.setProperty(key.to_s, value.to_s)
|
69
|
+
end
|
70
|
+
|
76
71
|
@tomcat.getService().addConnector(connector)
|
77
72
|
end
|
78
|
-
|
73
|
+
|
79
74
|
def add_ajp_connector
|
80
75
|
add_service_connector(@config[:ajp], 'AJP/1.3')
|
81
76
|
end
|
82
|
-
|
77
|
+
|
83
78
|
def add_ssl_connector
|
84
|
-
@config[:
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
79
|
+
options = @config[:ssl].merge({
|
80
|
+
:scheme => 'https',
|
81
|
+
:secure => true,
|
82
|
+
:SSLEnabled => 'true'
|
83
|
+
})
|
84
|
+
options[:keystore] ||= 'ssl/keystore'
|
85
|
+
options[:keystorePass] ||= 'waduswadus'
|
86
|
+
|
87
|
+
add_service_connector(options)
|
88
|
+
create_default_keystore(options) unless File.exist?(options[:keystore])
|
94
89
|
end
|
95
|
-
|
90
|
+
|
96
91
|
def ssl_enabled?
|
97
|
-
@config.has_key?(:ssl)
|
92
|
+
@config.has_key?(:ssl)
|
98
93
|
end
|
99
|
-
|
94
|
+
|
100
95
|
def ajp_enabled?
|
101
96
|
@config.has_key?(:ajp)
|
102
97
|
end
|
103
|
-
|
98
|
+
|
104
99
|
def create_default_keystore(config)
|
105
100
|
keystore_file = java.io.File.new(config[:ssl][:keystore])
|
106
|
-
|
101
|
+
|
107
102
|
if (!keystore_file.parent_file.exists() &&
|
108
103
|
!keystore_file.parent_file.mkdir())
|
109
104
|
raise "Unable to create keystore folder: " + keystore_file.parent_file.canonical_path
|
110
105
|
end
|
111
|
-
|
106
|
+
|
112
107
|
keytool_args = ["-genkey",
|
113
108
|
"-alias", "localhost",
|
114
109
|
"-dname", "CN=localhost, OU=Trinidad, O=Trinidad, C=ES",
|
@@ -118,7 +113,7 @@ module Trinidad
|
|
118
113
|
"-keystore", config[:ssl][:keystore],
|
119
114
|
"-storepass", config[:ssl][:keystorePass],
|
120
115
|
"-keypass", config[:ssl][:keystorePass]]
|
121
|
-
|
116
|
+
|
122
117
|
Trinidad::Tomcat::KeyTool.main(keytool_args.to_java(:string))
|
123
118
|
end
|
124
119
|
|
@@ -141,18 +136,5 @@ module Trinidad
|
|
141
136
|
end
|
142
137
|
end
|
143
138
|
|
144
|
-
def configure_ssl!(config)
|
145
|
-
if config.has_key?(:ssl) || config[:web_apps].deep_key?(:ssl)
|
146
|
-
if (config.has_key?(:ssl))
|
147
|
-
config[:ssl][:keystore] ||= 'ssl/keystore'
|
148
|
-
config[:ssl][:keystorePass] ||= 'waduswadus'
|
149
|
-
end
|
150
|
-
|
151
|
-
config[:web_apps].each do |name, app|
|
152
|
-
app[:ssl] = config[:ssl] unless app.has_key?(:ssl)
|
153
|
-
app[:ssl][:keystore] = File.join(app[:web_app_dir], app[:ssl][:keystore]) if app.has_key?(:ssl)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
139
|
end
|
158
140
|
end
|
data/lib/trinidad/web_app.rb
CHANGED
@@ -41,15 +41,16 @@ module Trinidad
|
|
41
41
|
def add_init_params
|
42
42
|
[:jruby_min_runtimes, :jruby_max_runtimes].each do |param|
|
43
43
|
param_name = param.to_s.gsub(/_/, '.')
|
44
|
-
|
44
|
+
add_parameter_unless_exist(param_name, @config[param].to_s)
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
add_parameter_unless_exist('jruby.initial.runtimes', @config[:jruby_min_runtimes].to_s)
|
48
|
+
add_parameter_unless_exist('public.root', File.join('/', public_root))
|
49
49
|
end
|
50
50
|
|
51
51
|
def add_web_dir_resources
|
52
|
-
|
52
|
+
doc_base = File.join(@app[:web_app_dir], public_root)
|
53
|
+
@context.setDocBase(doc_base) if File.exist?(doc_base)
|
53
54
|
end
|
54
55
|
|
55
56
|
def add_rack_context_listener
|
@@ -121,5 +122,9 @@ module Trinidad
|
|
121
122
|
def environment
|
122
123
|
@app[:environment] || @config[:environment]
|
123
124
|
end
|
125
|
+
|
126
|
+
def add_parameter_unless_exist(name, value)
|
127
|
+
@context.addParameter(name, value) unless @context.findParameter(name)
|
128
|
+
end
|
124
129
|
end
|
125
130
|
end
|
@@ -1,41 +1,41 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe Trinidad::Server do
|
4
|
-
|
4
|
+
|
5
5
|
it "should have ssl disabled when config param is nil" do
|
6
6
|
server = Trinidad::Server.new
|
7
7
|
server.ssl_enabled?.should == false
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
it "should have ajp disabled when config param is nil" do
|
11
11
|
server = Trinidad::Server.new
|
12
12
|
server.ajp_enabled?.should == false
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
it "should have ssl enabled when config param is a number" do
|
16
16
|
server = Trinidad::Server.new({:ssl => {:port => 8443},
|
17
17
|
:web_app_dir => MOCK_WEB_APP_DIR})
|
18
|
-
|
18
|
+
|
19
19
|
server.ssl_enabled?.should == true
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should have ajp enabled when config param is a number" do
|
23
23
|
server = Trinidad::Server.new({:ajp => {:port => 8009}})
|
24
|
-
|
24
|
+
|
25
25
|
server.ajp_enabled?.should == true
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it "should have a connector with https scheme" do
|
29
29
|
server = Trinidad::Server.new({:ssl => {:port => 8443},
|
30
30
|
:web_app_dir => MOCK_WEB_APP_DIR})
|
31
|
-
|
31
|
+
|
32
32
|
server.tomcat.service.findConnectors().should have(1).connectors
|
33
33
|
server.tomcat.service.findConnectors()[0].scheme.should == 'https'
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
it "should have an ajp connector enabled" do
|
37
37
|
server = Trinidad::Server.new({:ajp => {:port => 8009}})
|
38
|
-
|
38
|
+
|
39
39
|
server.tomcat.service.findConnectors().should have(1).connectors
|
40
40
|
server.tomcat.service.findConnectors()[0].protocol.should == 'AJP/1.3'
|
41
41
|
end
|
@@ -58,7 +58,7 @@ describe Trinidad::Server do
|
|
58
58
|
|
59
59
|
context_loaded = server.tomcat.host.findChildren()
|
60
60
|
context_loaded.should have(3).web_apps
|
61
|
-
|
61
|
+
|
62
62
|
expected = ['/mock1', '/mock2', '/']
|
63
63
|
context_loaded.each do |context|
|
64
64
|
expected.delete(context.getPath()).should == context.getPath()
|
@@ -70,7 +70,7 @@ describe Trinidad::Server do
|
|
70
70
|
|
71
71
|
default_context_should_be_loaded(server.tomcat.host.findChildren())
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it "loads the default application from the current directory using the rackup file if :web_apps is not present" do
|
75
75
|
server = Trinidad::Server.new({
|
76
76
|
:web_app_dir => MOCK_WEB_APP_DIR,
|
@@ -34,7 +34,7 @@ describe Trinidad::WebApp do
|
|
34
34
|
it "should load custom jars" do
|
35
35
|
class_loader = org.jruby.util.JRubyClassLoader.new(JRuby.runtime.jruby_class_loader)
|
36
36
|
@web_app.add_application_libs(class_loader)
|
37
|
-
|
37
|
+
|
38
38
|
resource = class_loader.find_class('org.ho.yaml.Yaml')
|
39
39
|
resource.should_not == nil
|
40
40
|
end
|
@@ -60,10 +60,10 @@ describe Trinidad::WebApp do
|
|
60
60
|
start_context_with_web_xml
|
61
61
|
lambda { @web_app.add_init_params }.should_not raise_error
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "should load init params" do
|
65
65
|
@web_app.add_init_params
|
66
|
-
|
66
|
+
|
67
67
|
@web_app.context.findParameter('jruby.min.runtimes').should == '2'
|
68
68
|
@web_app.context.findParameter('jruby.max.runtimes').should == '6'
|
69
69
|
end
|
metadata
CHANGED
@@ -1,93 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trinidad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- David Calavera
|
7
|
+
- David Calavera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-08 00:00:00 +01:00
|
13
13
|
default_executable: trinidad
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rack
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: mocha
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
25
45
|
description:
|
26
46
|
email: calavera@apache.org
|
27
47
|
executables:
|
28
|
-
- trinidad
|
48
|
+
- trinidad
|
29
49
|
extensions: []
|
30
50
|
|
31
51
|
extra_rdoc_files:
|
32
|
-
- LICENSE
|
33
|
-
- README.rdoc
|
52
|
+
- LICENSE
|
53
|
+
- README.rdoc
|
34
54
|
files:
|
35
|
-
- History.txt
|
36
|
-
- LICENSE
|
37
|
-
- README.rdoc
|
38
|
-
- Rakefile
|
39
|
-
- VERSION
|
40
|
-
- bin/trinidad
|
41
|
-
- lib/trinidad.rb
|
42
|
-
- lib/trinidad/command_line_parser.rb
|
43
|
-
- lib/trinidad/core_ext.rb
|
44
|
-
- lib/trinidad/jars.rb
|
45
|
-
- lib/trinidad/rackup_web_app.rb
|
46
|
-
- lib/trinidad/rails_web_app.rb
|
47
|
-
- lib/trinidad/server.rb
|
48
|
-
- lib/trinidad/web_app.rb
|
49
|
-
- trinidad-libs/core-3.1.1.jar
|
50
|
-
- trinidad-libs/jasper-el.jar
|
51
|
-
- trinidad-libs/jasper-jdt.jar
|
52
|
-
- trinidad-libs/jasper.jar
|
53
|
-
- trinidad-libs/jetty-util-6.1.14.jar
|
54
|
-
- trinidad-libs/jruby-rack-0.9.5.jar
|
55
|
-
- trinidad-libs/jsp-2.1.jar
|
56
|
-
- trinidad-libs/jsp-api-2.1.jar
|
57
|
-
- trinidad-libs/servlet-api-2.5-6.1.14.jar
|
58
|
-
- trinidad-libs/tomcat-core.jar
|
59
|
-
- trinidad-libs/tomcat-dbcp.jar
|
60
|
-
- trinidad-libs/tomcat-jasper.jar
|
55
|
+
- History.txt
|
56
|
+
- LICENSE
|
57
|
+
- README.rdoc
|
58
|
+
- Rakefile
|
59
|
+
- VERSION
|
60
|
+
- bin/trinidad
|
61
|
+
- lib/trinidad.rb
|
62
|
+
- lib/trinidad/command_line_parser.rb
|
63
|
+
- lib/trinidad/core_ext.rb
|
64
|
+
- lib/trinidad/jars.rb
|
65
|
+
- lib/trinidad/rackup_web_app.rb
|
66
|
+
- lib/trinidad/rails_web_app.rb
|
67
|
+
- lib/trinidad/server.rb
|
68
|
+
- lib/trinidad/web_app.rb
|
69
|
+
- trinidad-libs/core-3.1.1.jar
|
70
|
+
- trinidad-libs/jasper-el.jar
|
71
|
+
- trinidad-libs/jasper-jdt.jar
|
72
|
+
- trinidad-libs/jasper.jar
|
73
|
+
- trinidad-libs/jetty-util-6.1.14.jar
|
74
|
+
- trinidad-libs/jruby-rack-0.9.5.jar
|
75
|
+
- trinidad-libs/jsp-2.1.jar
|
76
|
+
- trinidad-libs/jsp-api-2.1.jar
|
77
|
+
- trinidad-libs/servlet-api-2.5-6.1.14.jar
|
78
|
+
- trinidad-libs/tomcat-core.jar
|
79
|
+
- trinidad-libs/tomcat-dbcp.jar
|
80
|
+
- trinidad-libs/tomcat-jasper.jar
|
61
81
|
has_rdoc: true
|
62
82
|
homepage: http://calavera.github.com/trinidad
|
63
83
|
licenses: []
|
64
84
|
|
65
85
|
post_install_message:
|
66
86
|
rdoc_options:
|
67
|
-
- --charset=UTF-8
|
87
|
+
- --charset=UTF-8
|
68
88
|
require_paths:
|
69
|
-
- lib
|
89
|
+
- lib
|
70
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
91
|
requirements:
|
72
|
-
|
73
|
-
|
74
|
-
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
75
95
|
version:
|
76
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
97
|
requirements:
|
78
|
-
|
79
|
-
|
80
|
-
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
81
101
|
version:
|
82
102
|
requirements: []
|
83
103
|
|
84
104
|
rubyforge_project: trinidad
|
85
|
-
rubygems_version: 1.3.
|
105
|
+
rubygems_version: 1.3.5
|
86
106
|
signing_key:
|
87
107
|
specification_version: 3
|
88
108
|
summary: Simple library to run rails applications into an embedded Tomcat
|
89
109
|
test_files:
|
90
|
-
- spec/spec_helper.rb
|
91
|
-
- spec/trinidad/command_line_parser_spec.rb
|
92
|
-
- spec/trinidad/server_spec.rb
|
93
|
-
- spec/trinidad/web_app_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
- spec/trinidad/command_line_parser_spec.rb
|
112
|
+
- spec/trinidad/server_spec.rb
|
113
|
+
- spec/trinidad/web_app_spec.rb
|