trinidad 0.9.1 → 0.9.2
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/History.txt +8 -0
- data/README.rdoc +32 -12
- data/VERSION +1 -1
- data/lib/trinidad.rb +4 -0
- data/lib/trinidad/rackup_web_app.rb +4 -5
- data/lib/trinidad/server.rb +18 -13
- data/lib/trinidad/web_app.rb +16 -2
- data/spec/trinidad/fakeapp.rb +2 -2
- data/spec/trinidad/server_spec.rb +19 -4
- data/spec/trinidad/web_app_lifecycle_listener_spec.rb +1 -1
- data/spec/trinidad/web_app_spec.rb +43 -1
- metadata +6 -4
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.9.2 (2010-05-24)
|
2
|
+
|
3
|
+
* Autoload the rackup file when it's under the directory WEB-INF.
|
4
|
+
* Let jruby-rack reads the rackup file instead of passing its content as an init parameter.
|
5
|
+
* Allow to configure the rack servlet from the configuration options.
|
6
|
+
* Allow to use crt files to configure SSL
|
7
|
+
|
1
8
|
== 0.9.1 (2010-05-09)
|
2
9
|
|
3
10
|
* Move all configuration logic to a Lifecycle listener:
|
@@ -5,6 +12,7 @@
|
|
5
12
|
- Avoids workarounds in the hotdeploy extension.
|
6
13
|
* Disable more Tomcat's default behaviours. Process Tlds is also disabled.
|
7
14
|
* Allow to specify webapp extensions in the extensions root section.
|
15
|
+
* Allow to configure the Http connector.
|
8
16
|
|
9
17
|
== 0.9.0 (2010-04-28)
|
10
18
|
|
data/README.rdoc
CHANGED
@@ -11,22 +11,42 @@ This project was initially called "Tomcat-rails" but due to legal issues with th
|
|
11
11
|
|
12
12
|
== USAGE:
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
Rails applications:
|
15
|
+
|
16
|
+
$ cd myrailsapp
|
17
|
+
$ jruby -S trinidad
|
18
|
+
|
19
|
+
Rack applications:
|
20
|
+
|
21
|
+
$ cd myrackapplication
|
22
|
+
|
23
|
+
$ jruby -S trinidad -r path_to_rackup/rackup_file
|
24
|
+
|
25
|
+
or if the name of the file is config.ru
|
26
|
+
|
27
|
+
$ jruby -S trinidad -r path_to_rackup
|
28
|
+
|
29
|
+
or if config.ru is in the base directory
|
30
|
+
|
31
|
+
$ jruby -S trinidad -r
|
32
|
+
|
33
|
+
or if config.ru is under the directory WEB-INF
|
34
|
+
|
35
|
+
$ jruby -S trinidad
|
36
|
+
|
17
37
|
== CONFIGURATION:
|
18
38
|
|
19
39
|
Trinidad allows you to configure some parameters when the server is started from the command line, the following is a list of the currently supported options:
|
20
40
|
|
21
|
-
* -p, --port PORT
|
22
|
-
* -e, --env ENVIRONMENT
|
23
|
-
* -c, --context CONTEXT
|
24
|
-
* --lib, --jars LIBS_DIR
|
25
|
-
* --classes CLASSES_DIR
|
26
|
-
* --rackup [RACKUP_FILE] =>
|
27
|
-
* --public PUBLIC_DIR
|
28
|
-
* -t, --threadsafe
|
29
|
-
* -l, --load EXTENSION_NAME
|
41
|
+
* -p, --port PORT => port to bind to.
|
42
|
+
* -e, --env ENVIRONMENT => rails environment.
|
43
|
+
* -c, --context CONTEXT => application context path.
|
44
|
+
* --lib, --jars LIBS_DIR => directory containing jars.
|
45
|
+
* --classes CLASSES_DIR => directory containing classes.
|
46
|
+
* -r, --rackup [RACKUP_FILE] => run a provided rackup file instead of a rails application, by default it's config.ru.
|
47
|
+
* --public PUBLIC_DIR => specify the public directory for your application, by default it's 'public'.
|
48
|
+
* -t, --threadsafe => shortcut to work in threadsafe mode. Setting jruby_min_runtimes and jruby_max_runtimes to 1 in the configuration file the server behaves as the same way.
|
49
|
+
* -l, --load EXTENSION_NAME => loads an extension to use its command line options.
|
30
50
|
|
31
51
|
The server can also be configured from a yaml file. If a file is not especified, the server tries to load the file <em>config/tomcat.yml</em>. Within this file you can add other options like jruby.min.runtimes(:jruby_min_runtimes) or jruby.max.runtimes(:jruby_max_runtimes).
|
32
52
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.2
|
data/lib/trinidad.rb
CHANGED
@@ -3,14 +3,13 @@ module Trinidad
|
|
3
3
|
|
4
4
|
def init_params
|
5
5
|
super
|
6
|
-
|
6
|
+
if rackup_path = rackup
|
7
|
+
rackup_path = File.join(rackup_path, 'config.ru') if File.directory?(rackup_path)
|
8
|
+
add_parameter_unless_exist('rackup.path', rackup_path)
|
9
|
+
end
|
7
10
|
@params
|
8
11
|
end
|
9
12
|
|
10
13
|
def context_listener; 'org.jruby.rack.RackServletContextListener'; end
|
11
|
-
|
12
|
-
def rackup_script
|
13
|
-
File.read(File.join(web_app_dir, rackup))
|
14
|
-
end
|
15
14
|
end
|
16
15
|
end
|
data/lib/trinidad/server.rb
CHANGED
@@ -73,7 +73,7 @@ module Trinidad
|
|
73
73
|
connector.setProperty(key.to_s, value.to_s)
|
74
74
|
end
|
75
75
|
|
76
|
-
@tomcat.
|
76
|
+
@tomcat.service.add_connector(connector)
|
77
77
|
connector
|
78
78
|
end
|
79
79
|
|
@@ -87,11 +87,14 @@ module Trinidad
|
|
87
87
|
:secure => true,
|
88
88
|
:SSLEnabled => 'true'
|
89
89
|
})
|
90
|
-
|
91
|
-
options[:
|
90
|
+
|
91
|
+
if !options[:keystore] && !options[:SSLCertificateFile]
|
92
|
+
options[:keystore] = 'ssl/keystore'
|
93
|
+
options[:keystorePass] = 'waduswadus'
|
94
|
+
end
|
92
95
|
|
93
96
|
add_service_connector(options)
|
94
|
-
create_default_keystore(options)
|
97
|
+
create_default_keystore(options)
|
95
98
|
end
|
96
99
|
|
97
100
|
def add_http_connector
|
@@ -116,10 +119,12 @@ module Trinidad
|
|
116
119
|
end
|
117
120
|
|
118
121
|
def create_default_keystore(config)
|
122
|
+
return if !config[:keystore] || File.exist?(config[:keystore])
|
123
|
+
|
119
124
|
keystore_file = java.io.File.new(config[:keystore])
|
120
125
|
|
121
|
-
if (!keystore_file.parent_file.exists
|
122
|
-
!keystore_file.parent_file.mkdir
|
126
|
+
if (!keystore_file.parent_file.exists &&
|
127
|
+
!keystore_file.parent_file.mkdir)
|
123
128
|
raise "Unable to create keystore folder: " + keystore_file.parent_file.canonical_path
|
124
129
|
end
|
125
130
|
|
@@ -138,7 +143,7 @@ module Trinidad
|
|
138
143
|
|
139
144
|
def start
|
140
145
|
@tomcat.start
|
141
|
-
@tomcat.
|
146
|
+
@tomcat.server.await
|
142
147
|
end
|
143
148
|
|
144
149
|
private
|
@@ -156,19 +161,19 @@ module Trinidad
|
|
156
161
|
end
|
157
162
|
|
158
163
|
def enable_naming
|
159
|
-
@tomcat.
|
164
|
+
@tomcat.server.add_lifecycle_listener(Trinidad::Tomcat::NamingContextListener.new)
|
160
165
|
|
161
|
-
JSystem.
|
166
|
+
JSystem.set_property("catalina.useNaming", "true")
|
162
167
|
|
163
168
|
value = "org.apache.naming"
|
164
|
-
old_value = JSystem.
|
169
|
+
old_value = JSystem.get_property(JContext::URL_PKG_PREFIXES) || value
|
165
170
|
|
166
171
|
value = value + ":" + old_value unless old_value.include?(value)
|
167
|
-
JSystem.
|
172
|
+
JSystem.set_property(JContext::URL_PKG_PREFIXES, value)
|
168
173
|
|
169
|
-
value = JSystem.
|
174
|
+
value = JSystem.get_property(JContext::INITIAL_CONTEXT_FACTORY)
|
170
175
|
unless value
|
171
|
-
JSystem.
|
176
|
+
JSystem.set_property(JContext::INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory")
|
172
177
|
end
|
173
178
|
end
|
174
179
|
|
data/lib/trinidad/web_app.rb
CHANGED
@@ -3,7 +3,7 @@ module Trinidad
|
|
3
3
|
attr_reader :config, :app_config, :class_loader, :servlet
|
4
4
|
|
5
5
|
def self.create(config, app_config)
|
6
|
-
|
6
|
+
rackup?(app_config) ? RackupWebApp.new(config, app_config) : RailsWebApp.new(config, app_config)
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize(config, app_config, servlet_class = 'org.jruby.rack.RackServlet', servlet_name = 'RackServlet')
|
@@ -11,7 +11,8 @@ module Trinidad
|
|
11
11
|
@app_config = app_config
|
12
12
|
|
13
13
|
@class_loader = org.jruby.util.JRubyClassLoader.new(JRuby.runtime.jruby_class_loader)
|
14
|
-
|
14
|
+
|
15
|
+
configure_rack_servlet(servlet_class, servlet_name) unless rack_servlet_configured?
|
15
16
|
end
|
16
17
|
|
17
18
|
def rack_listener
|
@@ -77,5 +78,18 @@ module Trinidad
|
|
77
78
|
return $1
|
78
79
|
end
|
79
80
|
end
|
81
|
+
|
82
|
+
def configure_rack_servlet(servlet_class, servlet_name)
|
83
|
+
servlet_config = @config[:servlet] || @app_config[:servlet]
|
84
|
+
if servlet_config
|
85
|
+
servlet_class = servlet_config[:class]
|
86
|
+
servlet_name = servlet_config[:name]
|
87
|
+
end
|
88
|
+
@servlet = {:class => servlet_class, :name => servlet_name}
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.rackup?(app_config)
|
92
|
+
app_config.has_key?(:rackup) || !Dir['WEB-INF/**/config.ru'].empty?
|
93
|
+
end
|
80
94
|
end
|
81
95
|
end
|
data/spec/trinidad/fakeapp.rb
CHANGED
@@ -32,6 +32,7 @@ describe Trinidad::Server do
|
|
32
32
|
:web_app_dir => MOCK_WEB_APP_DIR})
|
33
33
|
|
34
34
|
server.ssl_enabled?.should be_true
|
35
|
+
File.exist?('ssl').should be_true
|
35
36
|
end
|
36
37
|
|
37
38
|
it "enables ajp when config param is a number" do
|
@@ -131,24 +132,38 @@ describe Trinidad::Server do
|
|
131
132
|
connector.get_property('maxKeepAliveRequests').should == 4
|
132
133
|
connector.get_property('socket.bufferPool').should == '1000'
|
133
134
|
end
|
134
|
-
|
135
|
+
|
135
136
|
it "adds the WebAppLifecycleListener to each webapp" do
|
136
137
|
server = Trinidad::Server.new({:web_app_dir => MOCK_WEB_APP_DIR})
|
137
138
|
app_context = server.tomcat.host.find_child('/')
|
138
|
-
|
139
|
+
|
139
140
|
app_context.find_lifecycle_listeners.map {|l| l.class.name }.should include('Trinidad::WebAppLifecycleListener')
|
140
141
|
end
|
141
|
-
|
142
|
+
|
142
143
|
it "loads application extensions from the root of the configuration" do
|
143
144
|
server = Trinidad::Server.new({
|
144
145
|
:web_app_dir => MOCK_WEB_APP_DIR,
|
145
146
|
:extensions => { :foo => {} }
|
146
147
|
})
|
147
|
-
|
148
|
+
|
148
149
|
app_context = server.tomcat.host.find_child('/')
|
149
150
|
app_context.doc_base.should == 'foo_app_extension'
|
150
151
|
end
|
151
152
|
|
153
|
+
it "doesn't create a default keystore when the option SSLCertificateFile is present in the ssl configuration options" do
|
154
|
+
require 'fileutils'
|
155
|
+
FileUtils.rm_rf 'ssl'
|
156
|
+
|
157
|
+
server = Trinidad::Server.new({
|
158
|
+
:ssl => {
|
159
|
+
:port => 8443,
|
160
|
+
:SSLCertificateFile => '/usr/local/ssl/server.crt'
|
161
|
+
},
|
162
|
+
:web_app_dir => MOCK_WEB_APP_DIR})
|
163
|
+
|
164
|
+
File.exist?('ssl').should be_false
|
165
|
+
end
|
166
|
+
|
152
167
|
def default_context_should_be_loaded(children)
|
153
168
|
children.should have(1).web_apps
|
154
169
|
children[0].doc_base.should == MOCK_WEB_APP_DIR
|
@@ -174,6 +174,6 @@ describe Trinidad::WebAppLifecycleListener do
|
|
174
174
|
listener.context = Trinidad::Tomcat::StandardContext.new
|
175
175
|
listener.configure_init_params
|
176
176
|
|
177
|
-
listener.context.find_parameter('rackup').should == "
|
177
|
+
listener.context.find_parameter('rackup.path').should == "config.ru"
|
178
178
|
end
|
179
179
|
end
|
@@ -75,7 +75,7 @@ describe Trinidad::WebApp do
|
|
75
75
|
})
|
76
76
|
|
77
77
|
parameters = app.init_params
|
78
|
-
parameters['rackup'].should
|
78
|
+
parameters['rackup.path'].should == 'config/config.ru'
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -130,4 +130,46 @@ describe Trinidad::WebApp do
|
|
130
130
|
app = Trinidad::WebApp.create(config, app_config)
|
131
131
|
app.extensions[:hotdeploy].should include(:delay)
|
132
132
|
end
|
133
|
+
|
134
|
+
it "creates a rackup application when the rackup file is under WEB-INF directory" do
|
135
|
+
FakeFS do
|
136
|
+
create_rackup_file('WEB-INF')
|
137
|
+
app = Trinidad::WebApp.create({}, {})
|
138
|
+
|
139
|
+
app.should be_an_instance_of(Trinidad::RackupWebApp)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it "doesn't add the rackup init parameter when the rackup file is under WEB-INF directory" do
|
144
|
+
FakeFS do
|
145
|
+
create_rackup_file('WEB-INF')
|
146
|
+
app = Trinidad::WebApp.create({}, {})
|
147
|
+
|
148
|
+
app.init_params.should_not include('rackup.path')
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
it "loads rackup file from a given directory" do
|
153
|
+
FakeFS do
|
154
|
+
create_rackup_file('rack')
|
155
|
+
app = Trinidad::WebApp.create({}, {
|
156
|
+
:web_app_dir => Dir.pwd,
|
157
|
+
:rackup => 'rack'
|
158
|
+
})
|
159
|
+
app.init_params.should include('rackup.path')
|
160
|
+
app.init_params['rackup.path'].should == 'rack/config.ru'
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it "allows to configure the servlet from the configuration options" do
|
165
|
+
app = Trinidad::WebApp.create({}, {
|
166
|
+
:servlet => {
|
167
|
+
:class => 'org.jruby.trinidad.FakeServlet',
|
168
|
+
:name => 'FakeServlet'
|
169
|
+
}
|
170
|
+
})
|
171
|
+
|
172
|
+
app.servlet[:class].should == 'org.jruby.trinidad.FakeServlet'
|
173
|
+
app.servlet[:name].should == 'FakeServlet'
|
174
|
+
end
|
133
175
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 2
|
9
|
+
version: 0.9.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David Calavera
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-24 00:00:00 +02:00
|
18
18
|
default_executable: trinidad
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -38,8 +38,10 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
segments:
|
41
|
+
- 1
|
41
42
|
- 0
|
42
|
-
|
43
|
+
- 1
|
44
|
+
version: 1.0.1
|
43
45
|
type: :runtime
|
44
46
|
version_requirements: *id002
|
45
47
|
- !ruby/object:Gem::Dependency
|