trinidad 1.4.5 → 1.4.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.
- checksums.yaml +7 -0
- data/Gemfile +3 -3
- data/History.md +25 -0
- data/LICENSE +2 -2
- data/lib/trinidad/command_line_parser.rb +34 -34
- data/lib/trinidad/configuration.rb +22 -22
- data/lib/trinidad/lifecycle/web_app/shared.rb +24 -19
- data/lib/trinidad/lifecycle/web_app/war.rb +7 -7
- data/lib/trinidad/logging.rb +1 -24
- data/lib/trinidad/server.rb +122 -68
- data/lib/trinidad/version.rb +1 -1
- data/lib/trinidad/web_app.rb +24 -12
- data/trinidad.gemspec +6 -5
- metadata +21 -33
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4324c8a8dacc58bba855257ddfc1296159002490
|
4
|
+
data.tar.gz: 4bbedc68ed6ac2515163b9a43d200f1f61de181d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 34e0a3221d65521854cd6dc9d51b05b3b22ec1591f920f130ea15da93d4a1903b598826567921d390224d424a6542d54e45785a335661a4f2ffa80496b766386
|
7
|
+
data.tar.gz: 79466df8eb49615db97e4381d7b185501001edce145d6eb122366444380da3073bcb6dcdff8ebd2103cef46824f3b3fd18ba18f8bb682f97e5eaeb101bc99561
|
data/Gemfile
CHANGED
@@ -16,7 +16,7 @@ end
|
|
16
16
|
gem 'sinatra', :require => nil, :group => :test
|
17
17
|
|
18
18
|
group :integration do
|
19
|
-
gem "rails", "~> 3.2.
|
20
|
-
gem "jruby-openssl"
|
21
|
-
#eval(File.read("spec/integration/rails32/Gemfile"), binding)
|
19
|
+
gem "rails", "~> 3.2.16"
|
20
|
+
gem "jruby-openssl" if JRUBY_VERSION < '1.7.0'
|
21
|
+
# eval(File.read("spec/integration/rails32/Gemfile"), binding)
|
22
22
|
end
|
data/History.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
## trinidad 1.4.6 (2013-12-28)
|
2
|
+
|
3
|
+
* default :port for SSL is now (a more Ruby-sh) 3443
|
4
|
+
* better handling of port/address for connectors when only one configured
|
5
|
+
e.g. in case users want https:// but not http://
|
6
|
+
* make sure we keep localhost for tomcat.server's address if not specified
|
7
|
+
* only generate 'dummy' SSL keystore if not done already (#117)
|
8
|
+
* getting more "strict" about jruby-rack and trinidad_jars gem versions
|
9
|
+
* use a custom context manager to have "truly" lazy (java) sessions (#123)
|
10
|
+
* improve thread-safe rails (4.0) auto-detection from environment files
|
11
|
+
* allow symlinks in assets FS e.g. public/assets might be linked (#120)
|
12
|
+
* do not default to 'localhost' (default host) but use :address as name (#119)
|
13
|
+
|
14
|
+
with (latest) JRuby-Rack 1.1.13 works on JRuby 1.6.x (even < 1.6.7) as well
|
15
|
+
|
16
|
+
## trinidad_jars 1.3.0 (2013-12-28)
|
17
|
+
|
18
|
+
* Tomcat 7.0.47 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
|
19
|
+
* re-invent the MessageFormatter in Java
|
20
|
+
* introduce Jerry - Tomcat's little companion
|
21
|
+
|
22
|
+
## trinidad_jars 1.2.5 (2013-11-14)
|
23
|
+
|
24
|
+
* Tomcat 7.0.42 http://tomcat.apache.org/tomcat-7.0-doc/changelog.html
|
25
|
+
|
1
26
|
## trinidad 1.4.5 (2013-06-14)
|
2
27
|
|
3
28
|
* server should set up AJP only (if HTTP not explicitly configured) (#113)
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
== Trinidad
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2013 Team Trinidad and contributors http://github.com/trinidad
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
a copy of this software and associated documentation files (the
|
@@ -23,6 +23,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
|
24
24
|
== Tomcat
|
25
25
|
|
26
|
-
Apache Tomcat (Copyright 1999-
|
26
|
+
Apache Tomcat (Copyright 1999-2013 The Apache Software Foundation)
|
27
27
|
is licensed under the Apache License, Version 2.0.
|
28
28
|
See http://www.apache.org/licenses/LICENSE-2.0 for details.
|
@@ -8,9 +8,9 @@ module Trinidad
|
|
8
8
|
def self.load(options = {})
|
9
9
|
CommandLineParser.new.load!(options)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
attr_reader :default_options
|
13
|
-
|
13
|
+
|
14
14
|
def initialize
|
15
15
|
@default_options = {}
|
16
16
|
end
|
@@ -46,7 +46,7 @@ module Trinidad
|
|
46
46
|
alias_method :load_configuration, :load!
|
47
47
|
|
48
48
|
DEFAULT_CONFIG_FILE = 'config/trinidad.{yml,rb}'
|
49
|
-
|
49
|
+
|
50
50
|
def config_file(base_dir = nil)
|
51
51
|
base_dir ||= Dir.pwd
|
52
52
|
if @config_file.nil? # false means do not use no config file
|
@@ -55,9 +55,9 @@ module Trinidad
|
|
55
55
|
@config_file && File.expand_path(@config_file, base_dir)
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
attr_writer :config_file
|
60
|
-
|
60
|
+
|
61
61
|
def options_parser
|
62
62
|
require 'optparse'
|
63
63
|
@parser ||= OptionParser.new do |opts|
|
@@ -69,61 +69,61 @@ module Trinidad
|
|
69
69
|
default_options[:root_dir] = dir
|
70
70
|
end
|
71
71
|
|
72
|
-
opts.on('-e', '--env ENVIRONMENT', 'rack (rails) environment',
|
72
|
+
opts.on('-e', '--env ENVIRONMENT', 'rack (rails) environment',
|
73
73
|
"default: #{default(:environment)}") do |env|
|
74
74
|
default_options[:environment] = env
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
opts.on('-r', '--rackup [RACKUP_FILE]', 'rackup configuration file',
|
78
78
|
"default: config.ru") do |rackup|
|
79
79
|
default_options[:rackup] = rackup || 'config.ru'
|
80
80
|
end
|
81
81
|
|
82
|
-
opts.on('--public', '--public PUBLIC_DIR', 'web application public root',
|
82
|
+
opts.on('--public', '--public PUBLIC_DIR', 'web application public root',
|
83
83
|
"default: #{default(:public)}") do |public|
|
84
84
|
default_options[:public] = public
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
opts.on('-c', '--context CONTEXT_PATH', 'application context path',
|
88
88
|
"default: #{default(:context_path)}") do |path|
|
89
89
|
default_options[:context_path] = path
|
90
90
|
end
|
91
|
-
|
92
|
-
opts.on('--monitor', '--monitor MONITOR_FILE', 'monitor for application re-deploys',
|
91
|
+
|
92
|
+
opts.on('--monitor', '--monitor MONITOR_FILE', 'monitor for application re-deploys',
|
93
93
|
"default: tmp/restart.txt") do |monitor|
|
94
94
|
default_options[:monitor] = monitor
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
opts.on('-t', '--threadsafe', 'force thread-safe mode (use single runtime)') do
|
98
98
|
default_options[:jruby_min_runtimes] = 1
|
99
99
|
default_options[:jruby_max_runtimes] = 1
|
100
100
|
end
|
101
|
-
|
102
|
-
opts.on('--runtimes MIN:MAX', 'use given number of min/max jruby runtimes',
|
103
|
-
"default: #{default(:jruby_min_runtimes)}:#{default(:jruby_max_runtimes)}") do
|
101
|
+
|
102
|
+
opts.on('--runtimes MIN:MAX', 'use given number of min/max jruby runtimes',
|
103
|
+
"default: #{default(:jruby_min_runtimes)}:#{default(:jruby_max_runtimes)}") do
|
104
104
|
|min_max| min, max = min_max.split(':')
|
105
105
|
default_options[:jruby_min_runtimes] = min.to_i if min
|
106
106
|
default_options[:jruby_max_runtimes] = max.to_i if max
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
opts.on('-f', '--config [CONFIG_FILE]', 'configuration file',
|
110
110
|
"default: #{DEFAULT_CONFIG_FILE}") do |file|
|
111
111
|
self.config_file = file
|
112
112
|
end
|
113
|
-
|
114
|
-
opts.on('--address', '--address ADDRESS', 'host address',
|
113
|
+
|
114
|
+
opts.on('--address', '--address ADDRESS', 'host address',
|
115
115
|
"default: #{default(:address)}") do |address|
|
116
116
|
default_options[:address] = address
|
117
117
|
end
|
118
|
-
|
119
|
-
opts.on('-p', '--port PORT', 'port to bind to',
|
120
|
-
"default: #{default(:port)}") do |port|
|
118
|
+
|
119
|
+
opts.on('-p', '--port PORT', 'port to bind to',
|
120
|
+
"default: #{default(:port)}") do |port|
|
121
121
|
default_options[:port] = port
|
122
122
|
end
|
123
123
|
|
124
124
|
opts.on('-s', '--ssl [SSL_PORT]', 'enable secure socket layout',
|
125
|
-
"default port:
|
126
|
-
default_options[:ssl] = { :port => (port ||
|
125
|
+
"default port: 3443") do |port|
|
126
|
+
default_options[:ssl] = { :port => (port || 3443).to_i }
|
127
127
|
end
|
128
128
|
|
129
129
|
opts.on('-a', '--ajp [AJP_PORT]', 'enable the AJP web protocol',
|
@@ -131,13 +131,13 @@ module Trinidad
|
|
131
131
|
default_options[:ajp] = { :port => (port || 8009).to_i }
|
132
132
|
end
|
133
133
|
|
134
|
-
opts.on('--java_lib LIB_DIR', '--lib LIB_DIR (deprecated use --java_lib)',
|
134
|
+
opts.on('--java_lib LIB_DIR', '--lib LIB_DIR (deprecated use --java_lib)',
|
135
135
|
'contains .jar files used by the app',
|
136
136
|
"default: #{default(:java_lib)}") do |lib|
|
137
137
|
default_options[:java_lib] = lib
|
138
138
|
end
|
139
139
|
|
140
|
-
opts.on('--java_classes CLASSES_DIR', '--classes CLASSES_DIR (deprecated use --java_classes)',
|
140
|
+
opts.on('--java_classes CLASSES_DIR', '--classes CLASSES_DIR (deprecated use --java_classes)',
|
141
141
|
'contains java classes used by the app',
|
142
142
|
"default: #{default_java_classes}") do |classes|
|
143
143
|
default_options[:java_classes] = classes
|
@@ -149,37 +149,37 @@ module Trinidad
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
opts.on('--apps_base APPS_BASE_DIR', '--apps APPS_BASE_DIR (deprecated use --apps_base)',
|
152
|
+
opts.on('--apps_base APPS_BASE_DIR', '--apps APPS_BASE_DIR (deprecated use --apps_base)',
|
153
153
|
'set applications base directory') do |apps_base|
|
154
154
|
default_options[:apps_base] = apps_base
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
157
|
opts.on('-g', '--log LEVEL', 'set logging level') do |log|
|
158
158
|
default_options[:log] = log
|
159
159
|
end
|
160
|
-
|
160
|
+
|
161
161
|
opts.on('-v', '--version', 'show server version') do
|
162
162
|
puts "Trinidad #{Trinidad::VERSION} (Tomcat #{Trinidad::TOMCAT_VERSION})"
|
163
163
|
exit
|
164
164
|
end
|
165
|
-
|
165
|
+
|
166
166
|
opts.on('-h', '--help', 'display this help') do
|
167
167
|
puts opts
|
168
168
|
exit
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|
172
|
-
|
172
|
+
|
173
173
|
private
|
174
|
-
|
174
|
+
|
175
175
|
def default(key)
|
176
176
|
default_options[key] || Configuration::DEFAULTS[key]
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
179
|
def default_java_classes
|
180
|
-
default(:java_classes) ||
|
180
|
+
default(:java_classes) ||
|
181
181
|
( default(:java_lib) && File.join(default(:java_lib), 'classes') )
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
end
|
185
185
|
end
|
@@ -3,7 +3,7 @@ module Trinidad
|
|
3
3
|
attr_accessor :configuration
|
4
4
|
end
|
5
5
|
|
6
|
-
# Creates a new global configuration (unless already exists) and
|
6
|
+
# Creates a new global configuration (unless already exists) and
|
7
7
|
# (deep) merges the current values using the provided options.
|
8
8
|
def self.configure(*args)
|
9
9
|
config = ( self.configuration ||= Configuration.new )
|
@@ -16,7 +16,7 @@ module Trinidad
|
|
16
16
|
end
|
17
17
|
config.update!(options)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
yield config if block_given?
|
21
21
|
config
|
22
22
|
end
|
@@ -26,34 +26,34 @@ module Trinidad
|
|
26
26
|
self.configuration = Configuration.new
|
27
27
|
configure(*args, &block)
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
# Trinidad's (global) configuration instance.
|
31
|
-
# Use Trinidad#configure to update and obtain the global instance or access
|
31
|
+
# Use Trinidad#configure to update and obtain the global instance or access
|
32
32
|
# the instance using Trinidad#configuration
|
33
33
|
class Configuration
|
34
|
-
|
34
|
+
|
35
35
|
DEFAULTS = {
|
36
|
-
:port => 3000,
|
36
|
+
# :port => 3000, HTTP (depends on connector used)
|
37
37
|
:address => 'localhost',
|
38
38
|
:environment => 'development',
|
39
39
|
:context_path => '/',
|
40
40
|
:public => 'public',
|
41
41
|
:java_lib => 'lib/java',
|
42
42
|
:default_web_xml => 'config/web.xml',
|
43
|
-
:jruby_min_runtimes =>
|
43
|
+
:jruby_min_runtimes =>
|
44
44
|
java.lang.System.getProperty('jruby.min.runtimes') || 1,
|
45
|
-
:jruby_max_runtimes =>
|
45
|
+
:jruby_max_runtimes =>
|
46
46
|
java.lang.System.getProperty('jruby.max.runtimes') || 5,
|
47
47
|
:log => 'INFO',
|
48
48
|
:trap => true
|
49
49
|
}
|
50
|
-
|
50
|
+
|
51
51
|
def initialize(options = {})
|
52
52
|
@config = DEFAULTS.clone
|
53
53
|
update!(options)
|
54
54
|
end
|
55
55
|
|
56
|
-
def [](name)
|
56
|
+
def [](name)
|
57
57
|
@config[name.to_sym]
|
58
58
|
end
|
59
59
|
|
@@ -65,37 +65,37 @@ module Trinidad
|
|
65
65
|
@config.has_key?(name.to_sym)
|
66
66
|
end
|
67
67
|
alias_method :key?, :has_key?
|
68
|
-
|
68
|
+
|
69
69
|
def keys
|
70
70
|
@config.keys
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
def each(&block)
|
74
74
|
@config.each(&block)
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def update!(options)
|
78
78
|
options.each do |key, value|
|
79
79
|
self[key] = value.respond_to?(:strip) ? value.strip : value
|
80
80
|
end
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
%w{ port address environment context_path
|
84
84
|
java_lib libs_dir java_classes classes_dir default_web_xml
|
85
85
|
jruby_min_runtimes jruby_max_runtimes jruby_compat_version
|
86
86
|
rackup servlet rack_servlet default_servlet public hosts
|
87
|
-
http ajp ssl extensions
|
87
|
+
http ajp ssl https extensions
|
88
88
|
apps_base web_apps web_app_dir
|
89
89
|
monitor reload_strategy log trap }.each do |method|
|
90
90
|
class_eval "def #{method}; self[:'#{method}']; end"
|
91
91
|
class_eval "def #{method}=(value); self[:'#{method}'] = value; end"
|
92
92
|
end
|
93
93
|
# TODO #deprecate libs_dir classes_dir servlet
|
94
|
-
|
94
|
+
|
95
95
|
# a Hash like #symbolize helper
|
96
96
|
def self.symbolize_options(options, deep = true)
|
97
97
|
new_options = options.class.new
|
98
|
-
options.each do |key, value|
|
98
|
+
options.each do |key, value|
|
99
99
|
if deep && value.is_a?(Array) # YAML::Omap is an Array
|
100
100
|
array = new_options[key.to_sym] = value.class.new
|
101
101
|
value.each do |v|
|
@@ -109,13 +109,13 @@ module Trinidad
|
|
109
109
|
end
|
110
110
|
new_options
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
# a Hash like deep_merge helper
|
114
114
|
def self.merge_options(target, current, deep = true)
|
115
115
|
return target unless current
|
116
116
|
target_dup = target.dup
|
117
117
|
current.keys.each do |key|
|
118
|
-
target_dup[key] =
|
118
|
+
target_dup[key] =
|
119
119
|
if deep && options_like?(target[key]) && options_like?(current[key])
|
120
120
|
merge_options(target[key], current[key], deep)
|
121
121
|
else
|
@@ -124,12 +124,12 @@ module Trinidad
|
|
124
124
|
end
|
125
125
|
target_dup
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
private
|
129
129
|
def self.options_like?(object)
|
130
|
-
object.is_a?(Hash) ||
|
130
|
+
object.is_a?(Hash) ||
|
131
131
|
( object.respond_to?(:keys) && object.respond_to?(:'[]') )
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
end
|
135
135
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Trinidad
|
2
2
|
module Lifecycle
|
3
3
|
module WebApp
|
4
|
-
# Shared web application lifecycle hook,
|
4
|
+
# Shared web application lifecycle hook,
|
5
5
|
# does #configure before the context starts.
|
6
6
|
module Shared
|
7
7
|
|
@@ -23,7 +23,7 @@ module Trinidad
|
|
23
23
|
super
|
24
24
|
configure(event.lifecycle)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
# Configure the web application before it's started.
|
28
28
|
def configure(context)
|
29
29
|
adjust_context(context)
|
@@ -34,7 +34,7 @@ module Trinidad
|
|
34
34
|
end
|
35
35
|
|
36
36
|
protected
|
37
|
-
|
37
|
+
|
38
38
|
def adjust_context(context)
|
39
39
|
context_name = web_app.context_name
|
40
40
|
# on (rolling) reloads the name may have been set already :
|
@@ -45,7 +45,8 @@ module Trinidad
|
|
45
45
|
context.doc_base = web_app.doc_base if web_app.doc_base
|
46
46
|
context.work_dir = web_app.work_dir if web_app.work_dir
|
47
47
|
context.aliases = web_app.aliases if web_app.aliases
|
48
|
-
|
48
|
+
context.allow_linking = web_app.allow_linking
|
49
|
+
|
49
50
|
context.caching_allowed = web_app.caching_allowed?
|
50
51
|
context.cache_ttl = web_app.cache_ttl if web_app.cache_ttl
|
51
52
|
if max_size = web_app.cache_max_size
|
@@ -54,26 +55,30 @@ module Trinidad
|
|
54
55
|
if object_max_size = web_app.cache_object_max_size
|
55
56
|
context.cache_object_max_size = object_max_size
|
56
57
|
end
|
58
|
+
|
59
|
+
if manager = web_app.context_manager
|
60
|
+
context.manager = manager # replace "standard" (session) manager
|
61
|
+
end
|
57
62
|
end
|
58
|
-
|
63
|
+
|
59
64
|
def configure_default_servlet(context)
|
60
|
-
configure_builtin_servlet(context,
|
65
|
+
configure_builtin_servlet(context,
|
61
66
|
web_app.default_servlet, Trinidad::WebApp::DEFAULT_SERVLET_NAME
|
62
67
|
)
|
63
68
|
end
|
64
|
-
|
69
|
+
|
65
70
|
def configure_jsp_servlet(context)
|
66
|
-
wrapper = configure_builtin_servlet(context,
|
71
|
+
wrapper = configure_builtin_servlet(context,
|
67
72
|
web_app.jsp_servlet, Trinidad::WebApp::JSP_SERVLET_NAME
|
68
73
|
)
|
69
74
|
context.process_tlds = false if wrapper == false # jsp servlet removed
|
70
75
|
wrapper
|
71
76
|
end
|
72
|
-
|
77
|
+
|
73
78
|
def configure_logging(context)
|
74
79
|
Trinidad::Logging.configure_web_app(web_app, context)
|
75
80
|
end
|
76
|
-
|
81
|
+
|
77
82
|
private
|
78
83
|
|
79
84
|
def configure_builtin_servlet(context, servlet_config, name)
|
@@ -98,7 +103,7 @@ module Trinidad
|
|
98
103
|
wrapper.servlet_class = servlet_class
|
99
104
|
end
|
100
105
|
# do not remove wrapper but only "update" the default :
|
101
|
-
wrapper.load_on_startup = ( servlet_config[:load_on_startup] ||
|
106
|
+
wrapper.load_on_startup = ( servlet_config[:load_on_startup] ||
|
102
107
|
name_wrapper.load_on_startup ).to_i
|
103
108
|
add_init_params(wrapper, servlet_config[:init_params])
|
104
109
|
if mapping = servlet_config[:mapping]
|
@@ -110,13 +115,13 @@ module Trinidad
|
|
110
115
|
wrapper
|
111
116
|
end
|
112
117
|
end
|
113
|
-
|
118
|
+
|
114
119
|
def remove_defaults(context)
|
115
120
|
context.remove_welcome_file('index.htm')
|
116
121
|
context.remove_welcome_file('index.html')
|
117
122
|
context.remove_welcome_file('index.jsp')
|
118
123
|
end
|
119
|
-
|
124
|
+
|
120
125
|
def add_init_params(wrapper, params)
|
121
126
|
return unless params
|
122
127
|
params.each do |param, value|
|
@@ -124,22 +129,22 @@ module Trinidad
|
|
124
129
|
wrapper.add_init_parameter(param.to_s, val)
|
125
130
|
end
|
126
131
|
end
|
127
|
-
|
132
|
+
|
128
133
|
def add_servlet_mapping(context, mapping, name)
|
129
|
-
if mapping.is_a?(String) || mapping.is_a?(Symbol)
|
134
|
+
if mapping.is_a?(String) || mapping.is_a?(Symbol)
|
130
135
|
context.add_servlet_mapping(mapping.to_s, name)
|
131
136
|
else
|
132
137
|
mapping.each { |m| add_servlet_mapping(context, m, name) }
|
133
138
|
end
|
134
139
|
end
|
135
|
-
|
140
|
+
|
136
141
|
# Remove all servlet mappings for given (servlet) name.
|
137
142
|
def remove_servlet_mapping(context, name)
|
138
143
|
find_servlet_mapping(context, name).each do
|
139
144
|
|pattern| context.remove_servlet_mapping(pattern)
|
140
145
|
end
|
141
146
|
end
|
142
|
-
|
147
|
+
|
143
148
|
# Find all servlet mappings for given (servlet) name.
|
144
149
|
def find_servlet_mapping(context, name)
|
145
150
|
name_mapping = []
|
@@ -149,12 +154,12 @@ module Trinidad
|
|
149
154
|
end
|
150
155
|
name_mapping
|
151
156
|
end
|
152
|
-
|
157
|
+
|
153
158
|
def logger
|
154
159
|
@logger ||= Trinidad::Logging::LogFactory.
|
155
160
|
getLog('org.apache.catalina.core.StandardContext')
|
156
161
|
end
|
157
|
-
|
162
|
+
|
158
163
|
end
|
159
164
|
end
|
160
165
|
end
|
@@ -6,7 +6,7 @@ module Trinidad
|
|
6
6
|
module WebApp
|
7
7
|
class War < Base
|
8
8
|
include Shared
|
9
|
-
|
9
|
+
|
10
10
|
def before_init(event)
|
11
11
|
# NOTE: esp. important for .war applications that the name matches the path
|
12
12
|
# to work-around ProxyDirContext constructor's `contextPath = contextName;`
|
@@ -15,21 +15,21 @@ module Trinidad
|
|
15
15
|
context.name = context.path if context.name
|
16
16
|
super
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def configure(context)
|
20
20
|
super # Shared#configure
|
21
21
|
configure_class_loader(context)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
protected
|
25
|
-
|
25
|
+
|
26
26
|
def adjust_context(context)
|
27
27
|
name = context.name
|
28
28
|
super
|
29
29
|
ensure # @see {#before_init}
|
30
30
|
context.name = name
|
31
|
-
# NOTE: mimics HostConfig#
|
32
|
-
# once Lifecycle::Host inherits
|
31
|
+
# NOTE: mimics HostConfig#deployWAR and might/should be removed
|
32
|
+
# once Lifecycle::Host inherits functionality from HostConfig ...
|
33
33
|
# context_name = Trinidad::Tomcat::ContextName.new(name)
|
34
34
|
# context.setName context_name.getName()
|
35
35
|
# context.setPath context_name.getPath()
|
@@ -47,7 +47,7 @@ module Trinidad
|
|
47
47
|
def remove_defaults(context = nil)
|
48
48
|
# NOTE: do not remove defaults (welcome files)
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
end
|
52
52
|
end
|
53
53
|
War = Trinidad::Lifecycle::WebApp::War # backwards compatibility
|
data/lib/trinidad/logging.rb
CHANGED
@@ -188,30 +188,7 @@ module Trinidad
|
|
188
188
|
end
|
189
189
|
|
190
190
|
# A message formatter only prints the log message (and the thrown value).
|
191
|
-
|
192
|
-
|
193
|
-
def format(record)
|
194
|
-
msg = formatMessage(record)
|
195
|
-
msg << formatThrown(record).to_s
|
196
|
-
# since we're going to print Rails.logger logs and they tend
|
197
|
-
# to already have the ending "\n" handle such cases nicely :
|
198
|
-
if context_name(record.getLoggerName)
|
199
|
-
(lns = LINE_SEP) == msg[-1, 1] ? msg : msg << lns
|
200
|
-
else
|
201
|
-
msg << LINE_SEP
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
# e.g. org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/foo]
|
206
|
-
# or org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[default]
|
207
|
-
WEB_APP_LOGGER_NAME = /^org\.apache\.catalina\.core\.ContainerBase.*?\[(.*?)\]$/
|
208
|
-
|
209
|
-
private
|
210
|
-
def context_name(name)
|
211
|
-
( match = (name || '').match(WEB_APP_LOGGER_NAME) ) && match[1]
|
212
|
-
end
|
213
|
-
|
214
|
-
end
|
191
|
+
MessageFormatter = Java::RbTrinidadLogging::MessageFormatter
|
215
192
|
|
216
193
|
DefaultFormatter = Java::RbTrinidadLogging::DefaultFormatter
|
217
194
|
|
data/lib/trinidad/server.rb
CHANGED
@@ -10,7 +10,7 @@ module Trinidad
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def configure(config = Trinidad.configuration)
|
13
|
-
configure_logging config[:log]
|
13
|
+
configure_logging config[:logging] || config[:log]
|
14
14
|
@config = config.freeze
|
15
15
|
end
|
16
16
|
# @deprecated replaced with {#configure}
|
@@ -39,11 +39,14 @@ module Trinidad
|
|
39
39
|
|
40
40
|
def ssl_enabled?
|
41
41
|
if ! defined?(@ssl_enabled) || @ssl_enabled.nil?
|
42
|
-
|
42
|
+
ssl = @config.key?(:https) ? @config[:https] : @config[:ssl]
|
43
|
+
@ssl_enabled = ( !! ssl && ( ! ssl.respond_to?(:empty?) || ! ssl.empty? ) )
|
43
44
|
end
|
44
45
|
@ssl_enabled
|
45
46
|
end
|
46
47
|
attr_writer :ssl_enabled
|
48
|
+
alias_method :https_enabled?, :ssl_enabled?
|
49
|
+
alias_method :https_enabled=, :ssl_enabled=
|
47
50
|
|
48
51
|
def ajp_enabled?
|
49
52
|
if ! defined?(@ajp_enabled) || @ajp_enabled.nil?
|
@@ -61,37 +64,49 @@ module Trinidad
|
|
61
64
|
end
|
62
65
|
@http_configured
|
63
66
|
end
|
64
|
-
|
67
|
+
# @deprecated
|
68
|
+
def http_configured=(flag); @http_configured = flag end
|
65
69
|
|
66
70
|
def tomcat; @tomcat ||= initialize_tomcat; end
|
67
71
|
|
68
|
-
LOCALHOST = 'localhost'.freeze # :nodoc:
|
69
|
-
|
70
72
|
def initialize_tomcat
|
71
73
|
set_system_properties
|
72
74
|
|
73
|
-
tomcat = Trinidad::Tomcat
|
75
|
+
tomcat = Tomcat.new # @see Trinidad::Tomcat
|
74
76
|
tomcat.base_dir = config[:base_dir] || Dir.pwd
|
75
|
-
|
76
|
-
tomcat.
|
77
|
-
tomcat.
|
77
|
+
address = config[:address] if config.key?(:address)
|
78
|
+
tomcat.hostname = address || 'localhost'
|
79
|
+
tomcat.server.address = address || nil unless address.nil?
|
80
|
+
tomcat.port = config[:port].to_i if config.key?(:port)
|
78
81
|
default_host(tomcat)
|
79
82
|
create_hosts(tomcat)
|
80
83
|
tomcat.enable_naming
|
81
84
|
|
82
|
-
http_connector = http_configured? ||
|
83
|
-
|
85
|
+
http_connector = http_configured? || ( ! ajp_enabled? && ! ssl_enabled? )
|
86
|
+
|
87
|
+
tomcat.connector = add_http_connector(config[:http], tomcat) if http_connector
|
84
88
|
|
85
|
-
if
|
86
|
-
|
89
|
+
if ssl_enabled?
|
90
|
+
options = config.key?(:https) ? config[:https] : config[:ssl]
|
91
|
+
options = {} if options == true
|
92
|
+
unless options.key?(:port)
|
93
|
+
options[:port] = http_connector ? 3443 : config[:port] || 3443
|
94
|
+
end
|
95
|
+
connector = add_ssl_connector(options, tomcat)
|
96
|
+
tomcat.connector = connector unless http_connector
|
97
|
+
http_connector = true # tomcat.connector http: or https: or ajp:
|
87
98
|
end
|
99
|
+
|
88
100
|
if ajp_enabled?
|
89
|
-
|
101
|
+
options = config[:ajp]; options = {} if options == true
|
102
|
+
unless options.key?(:port)
|
103
|
+
options[:port] = config[:port] || 8009 unless http_connector
|
104
|
+
end
|
105
|
+
connector = add_ajp_connector(options, tomcat)
|
90
106
|
tomcat.connector = connector unless http_connector
|
91
107
|
end
|
92
|
-
add_ssl_connector(tomcat) if ssl_enabled?
|
93
108
|
|
94
|
-
|
109
|
+
Extensions.configure_server_extensions(config[:extensions], tomcat)
|
95
110
|
end
|
96
111
|
protected :initialize_tomcat
|
97
112
|
# #deprecated renamed to {#initialize_tomcat}
|
@@ -99,65 +114,99 @@ module Trinidad
|
|
99
114
|
|
100
115
|
def add_host_monitor(app_holders)
|
101
116
|
for host in tomcat.engine.find_children
|
102
|
-
host_apps = select_host_apps(app_holders, host)
|
103
|
-
host.add_lifecycle_listener(
|
117
|
+
host_apps = select_host_apps(app_holders, host, tomcat)
|
118
|
+
host.add_lifecycle_listener(Lifecycle::Host.new(self, *host_apps))
|
104
119
|
end
|
105
120
|
end
|
106
121
|
protected :add_host_monitor
|
107
122
|
# @deprecated replaced with {#setup_host_monitor}
|
108
123
|
def load_host_monitor(web_apps); add_host_monitor(web_apps); end
|
109
124
|
|
110
|
-
def add_ajp_connector(tomcat =
|
111
|
-
|
112
|
-
options
|
113
|
-
|
114
|
-
|
125
|
+
def add_ajp_connector(options = config[:ajp], tomcat = nil)
|
126
|
+
# backwards compatibility - single argument (tomcat = @tomcat)
|
127
|
+
if options && ! options.respond_to?(:[])
|
128
|
+
tomcat = options; options = config[:ajp]
|
129
|
+
else
|
130
|
+
tomcat = @tomcat
|
131
|
+
end if tomcat.nil?
|
132
|
+
|
133
|
+
options = options.respond_to?(:[]) ? options.dup : {}
|
134
|
+
options[:address] = config[:address] unless options.key?(:address)
|
115
135
|
|
116
|
-
add_service_connector(options,
|
136
|
+
add_service_connector(options, 'AJP/1.3', tomcat)
|
117
137
|
end
|
118
138
|
|
119
|
-
def add_http_connector(tomcat =
|
120
|
-
|
121
|
-
options
|
122
|
-
|
123
|
-
|
139
|
+
def add_http_connector(options = config[:http], tomcat = nil)
|
140
|
+
# backwards compatibility - single argument (tomcat = @tomcat)
|
141
|
+
if options && ! options.respond_to?(:[])
|
142
|
+
tomcat = options; options = config[:http]
|
143
|
+
else
|
144
|
+
tomcat = @tomcat
|
145
|
+
end if tomcat.nil?
|
146
|
+
|
147
|
+
options = options.respond_to?(:[]) ? options.dup : {}
|
148
|
+
options[:port] = config[:port] || 3000 unless options.key?(:port)
|
149
|
+
options[:address] = config[:address] unless options.key?(:address)
|
124
150
|
|
125
151
|
if options.delete(:nio)
|
126
152
|
options[:protocol_handler] ||= 'org.apache.coyote.http11.Http11NioProtocol'
|
127
153
|
end
|
128
154
|
|
129
155
|
if options.delete(:apr)
|
130
|
-
tomcat.server.add_lifecycle_listener(
|
156
|
+
tomcat.server.add_lifecycle_listener(Tomcat::AprLifecycleListener.new)
|
131
157
|
end
|
132
158
|
|
133
|
-
add_service_connector(options,
|
159
|
+
add_service_connector(options, 'HTTP/1.1', tomcat)
|
134
160
|
end
|
135
161
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
162
|
+
# @private
|
163
|
+
DEFAULT_KEYSTORE_FILE = 'ssl/keystore' # TODO review default location
|
164
|
+
|
165
|
+
def add_ssl_connector(options = config[:ssl], tomcat = nil)
|
166
|
+
# backwards compatibility - single argument (tomcat = @tomcat)
|
167
|
+
if options && ! options.respond_to?(:[])
|
168
|
+
tomcat = options; options = config[:ssl]
|
169
|
+
else
|
170
|
+
tomcat = @tomcat
|
171
|
+
end if tomcat.nil?
|
141
172
|
|
142
|
-
options
|
173
|
+
options = { :scheme => 'https', :secure => true }.merge!( options.respond_to?(:[]) ? options : {} )
|
174
|
+
options[:address] = config[:address] unless options.key?(:address)
|
175
|
+
|
176
|
+
if keystore_file = options.delete(:keystore) || options.delete(:keystore_file)
|
177
|
+
options[:keystoreFile] ||= keystore_file
|
178
|
+
end
|
179
|
+
options[:keystorePass] ||= options.delete(:keystore_pass) if options.key?(:keystore_pass)
|
180
|
+
# handle "custom" alternative SSL (casing) options :
|
181
|
+
options[:SSLEnabled] = options.delete(:ssl_enabled) || true # always true
|
182
|
+
options[:SSLCertificateFile] ||= options.delete(:ssl_certificate_file) if options.key?(:ssl_certificate_file)
|
183
|
+
options[:SSLCertificateKeyFile] ||= options.delete(:ssl_certificate_key_file) if options.key?(:ssl_certificate_key_file)
|
184
|
+
options[:SSLVerifyClient] ||= options.delete(:ssl_verify_client) if options.key?(:ssl_verify_client)
|
185
|
+
options[:SSLProtocol] ||= options.delete(:ssl_protocol) if options.key?(:ssl_protocol)
|
186
|
+
# NOTE: there's quite more SSL prefixed options with APR ...
|
143
187
|
|
144
188
|
if ! options[:keystoreFile] && ! options[:SSLCertificateFile]
|
145
|
-
|
146
|
-
options[:
|
147
|
-
|
189
|
+
# generate one for development/testing SSL :
|
190
|
+
options[:keystoreFile] = DEFAULT_KEYSTORE_FILE
|
191
|
+
options[:keystorePass] ||= 'waduswadus42' # NOTE change/ask for default
|
192
|
+
if File.exist?(DEFAULT_KEYSTORE_FILE)
|
193
|
+
logger.info "Using (default) keystore at #{DEFAULT_KEYSTORE_FILE.inspect}"
|
194
|
+
else
|
195
|
+
generate_default_keystore(options)
|
196
|
+
end
|
148
197
|
end
|
149
198
|
|
150
|
-
add_service_connector(options,
|
199
|
+
add_service_connector(options, 'HTTP/1.1', tomcat)
|
151
200
|
end
|
152
201
|
|
153
202
|
# NOTE: make sure to pass an options Hash that might be changed !
|
154
203
|
def add_service_connector(options, protocol = nil, tomcat = @tomcat)
|
155
|
-
connector =
|
156
|
-
connector.scheme = options.delete(:scheme) if options
|
157
|
-
connector.secure = options.delete(:secure)
|
204
|
+
connector = Tomcat::Connector.new(options.delete(:protocol) || protocol)
|
205
|
+
connector.scheme = options.delete(:scheme) if options.key?(:scheme)
|
206
|
+
connector.secure = options.key?(:secure) ? options.delete(:secure) : false
|
158
207
|
connector.port = options.delete(:port).to_i if options[:port]
|
159
208
|
|
160
|
-
if handler = options.delete(:protocol_handler)
|
209
|
+
if handler = options.delete(:protocol_handler) || options.delete(:protocol_handler_class_name)
|
161
210
|
connector.protocol_handler_class_name = handler
|
162
211
|
end
|
163
212
|
|
@@ -178,7 +227,7 @@ module Trinidad
|
|
178
227
|
host.start_children = start unless start.nil?
|
179
228
|
# public Context addWebapp(Host host, String url, String name, String docBase)
|
180
229
|
tomcat.addWebapp(host, web_app.context_path, web_app.context_name, web_app.root_dir)
|
181
|
-
rescue
|
230
|
+
rescue Java::JavaLang::IllegalArgumentException => e
|
182
231
|
if e.message =~ /addChild\:/
|
183
232
|
context_name = web_app.context_name
|
184
233
|
logger.error "could not add application #{context_name.inspect} from #{web_app.root_dir}\n" <<
|
@@ -189,7 +238,7 @@ module Trinidad
|
|
189
238
|
ensure
|
190
239
|
host.start_children = prev_start unless start.nil?
|
191
240
|
end
|
192
|
-
|
241
|
+
Extensions.configure_webapp_extensions(web_app.extensions, tomcat, context)
|
193
242
|
if lifecycle = web_app.define_lifecycle
|
194
243
|
context.add_lifecycle_listener(lifecycle)
|
195
244
|
end
|
@@ -197,7 +246,8 @@ module Trinidad
|
|
197
246
|
end
|
198
247
|
|
199
248
|
def deploy_web_apps(tomcat = self.tomcat)
|
200
|
-
|
249
|
+
web_apps = create_web_apps
|
250
|
+
add_host_monitor web_apps
|
201
251
|
web_apps
|
202
252
|
end
|
203
253
|
|
@@ -274,7 +324,7 @@ module Trinidad
|
|
274
324
|
app_base_name = File.basename(app_root)
|
275
325
|
deployed = apps.find do |app_holder|; web_app = app_holder.web_app
|
276
326
|
web_app.root_dir == app_root ||
|
277
|
-
web_app.context_path ==
|
327
|
+
web_app.context_path == Tomcat::ContextName.new(app_base_name).path
|
278
328
|
end
|
279
329
|
if deployed
|
280
330
|
logger.debug "Skipping auto-deploy from #{app_root} (already deployed)"
|
@@ -292,7 +342,7 @@ module Trinidad
|
|
292
342
|
end
|
293
343
|
|
294
344
|
def create_web_app(app_config)
|
295
|
-
host_name = app_config[:host_name] ||
|
345
|
+
host_name = app_config[:host_name] || tomcat.host.name
|
296
346
|
host = tomcat.engine.find_child(host_name)
|
297
347
|
app_config[:root_dir] = web_app_root_dir(app_config, host)
|
298
348
|
|
@@ -340,7 +390,7 @@ module Trinidad
|
|
340
390
|
end
|
341
391
|
|
342
392
|
def create_host(app_base, host_config, tomcat = @tomcat)
|
343
|
-
host =
|
393
|
+
host = Tomcat::StandardHost.new
|
344
394
|
host.app_base = nil # reset default app_base
|
345
395
|
host.deployXML = false # disabled by default
|
346
396
|
setup_host(app_base, host_config, host)
|
@@ -382,8 +432,8 @@ module Trinidad
|
|
382
432
|
# @deprecated renamed to {#set_system_properties}
|
383
433
|
def load_default_system_properties; set_system_properties; end
|
384
434
|
|
385
|
-
def configure_logging(
|
386
|
-
Trinidad::Logging.configure(
|
435
|
+
def configure_logging(logging)
|
436
|
+
Trinidad::Logging.configure(logging)
|
387
437
|
end
|
388
438
|
|
389
439
|
def logger; @logger ||= self.class.logger; end
|
@@ -406,7 +456,8 @@ module Trinidad
|
|
406
456
|
host
|
407
457
|
end
|
408
458
|
|
409
|
-
|
459
|
+
# @private
|
460
|
+
DEFAULT_HOST_APP_BASE = 'webapps'
|
410
461
|
|
411
462
|
def default_host_base?(host)
|
412
463
|
host.app_base.nil? || ( host.app_base == DEFAULT_HOST_APP_BASE && host.name == 'localhost' )
|
@@ -452,10 +503,10 @@ module Trinidad
|
|
452
503
|
end
|
453
504
|
end
|
454
505
|
|
455
|
-
def select_host_apps(app_holders, host)
|
506
|
+
def select_host_apps(app_holders, host, tomcat = self.tomcat)
|
456
507
|
app_holders.select do |app_holder|
|
457
508
|
host_name = app_holder.web_app.host_name
|
458
|
-
|
509
|
+
host_name ? host_name == host.name : host == tomcat.host # default host
|
459
510
|
end
|
460
511
|
end
|
461
512
|
|
@@ -506,25 +557,28 @@ module Trinidad
|
|
506
557
|
end
|
507
558
|
end
|
508
559
|
|
509
|
-
def generate_default_keystore(config)
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
560
|
+
def generate_default_keystore(file, pass = nil) # or (config)
|
561
|
+
file, pass = file[:keystoreFile], file[:keystorePass] if pass.nil?
|
562
|
+
file = Java::JavaIo::File.new(file)
|
563
|
+
keystore_dir = file.parent_file
|
564
|
+
if ! keystore_dir.exists && ! keystore_dir.mkdir
|
565
|
+
raise "Unable to create keystore folder: #{keystore_dir.canonical_path}"
|
514
566
|
end
|
515
567
|
|
516
|
-
key_tool_args = ["-genkey",
|
568
|
+
key_tool_args = [ "-genkey",
|
517
569
|
"-alias", "localhost",
|
518
|
-
"-dname", "CN=localhost, OU=Trinidad, O=Trinidad, C=ES",
|
570
|
+
"-dname", dname = "CN=localhost, OU=Trinidad, O=Trinidad, C=ES",
|
519
571
|
"-keyalg", "RSA",
|
520
572
|
"-validity", "365",
|
521
573
|
"-storepass", "key",
|
522
|
-
"-keystore",
|
523
|
-
"-storepass",
|
524
|
-
"-keypass",
|
574
|
+
"-keystore", file.absolute_path,
|
575
|
+
"-storepass", pass,
|
576
|
+
"-keypass", pass ]
|
577
|
+
|
578
|
+
logger.info "Generating a (default) keystore for localhost #{dname.inspect} at " <<
|
579
|
+
"#{file.canonical_path} (password: '#{pass}')"
|
525
580
|
|
526
|
-
|
527
|
-
key_tool.main key_tool_args.to_java(:string)
|
581
|
+
Java::SunSecurityTools::KeyTool.main key_tool_args.to_java(:string)
|
528
582
|
end
|
529
583
|
|
530
584
|
def trap_signals
|
data/lib/trinidad/version.rb
CHANGED
data/lib/trinidad/web_app.rb
CHANGED
@@ -3,7 +3,7 @@ require 'trinidad/configuration'
|
|
3
3
|
module Trinidad
|
4
4
|
class WebApp
|
5
5
|
|
6
|
-
@@defaults =
|
6
|
+
@@defaults = Configuration::DEFAULTS
|
7
7
|
|
8
8
|
attr_reader :config, :default_config
|
9
9
|
|
@@ -24,14 +24,18 @@ module Trinidad
|
|
24
24
|
config.key?(key) ? config[key] : default_config[key]
|
25
25
|
end
|
26
26
|
|
27
|
+
def []=(key, value)
|
28
|
+
config[key.to_sym] = value
|
29
|
+
end
|
30
|
+
|
27
31
|
def key?(key, use_default = true)
|
28
32
|
key = key.to_sym
|
29
33
|
return true if config.has_key?(key)
|
30
34
|
use_default ? default_config.key?(key) : false
|
31
35
|
end
|
32
36
|
|
33
|
-
%w{ root_dir rackup async_supported reload_strategy host_name }.each do
|
34
|
-
class_eval "def #{method}; self[:'#{method}']; end"
|
37
|
+
%w{ root_dir rackup async_supported reload_strategy host_name }.each do
|
38
|
+
|method| class_eval "def #{method}; self[:'#{method}']; end"
|
35
39
|
end
|
36
40
|
|
37
41
|
alias_method :web_app_dir, :root_dir # is getting deprecated soon
|
@@ -54,6 +58,8 @@ module Trinidad
|
|
54
58
|
# JRuby-Rack correctly resolves relative paths for the context!
|
55
59
|
def doc_base; self[:doc_base] || root_dir; end
|
56
60
|
|
61
|
+
def allow_linking; key?(:allow_linking) ? self[:allow_linking] : true; end
|
62
|
+
|
57
63
|
def jruby_min_runtimes
|
58
64
|
if min = config[:jruby_min_runtimes]
|
59
65
|
return min.to_i # min specified overrides :threadsafe
|
@@ -173,6 +179,9 @@ module Trinidad
|
|
173
179
|
end
|
174
180
|
end
|
175
181
|
|
182
|
+
# TODO: internal API - should be configurable/adjustable with context.yml !
|
183
|
+
def context_manager; Java::RbTrinidadContext::DefaultManager.new end
|
184
|
+
|
176
185
|
def logging
|
177
186
|
@logging ||= begin
|
178
187
|
defaults = {
|
@@ -185,7 +194,7 @@ module Trinidad
|
|
185
194
|
:rotate => true
|
186
195
|
}
|
187
196
|
}
|
188
|
-
|
197
|
+
Configuration.merge_options(defaults, self[:logging])
|
189
198
|
end
|
190
199
|
end
|
191
200
|
|
@@ -271,7 +280,7 @@ module Trinidad
|
|
271
280
|
def generate_class_loader; class_loader!; end
|
272
281
|
|
273
282
|
def define_lifecycle
|
274
|
-
|
283
|
+
Lifecycle::WebApp::Default.new(self)
|
275
284
|
end
|
276
285
|
|
277
286
|
# Reset the hold web application state so it gets re-initialized.
|
@@ -394,7 +403,7 @@ module Trinidad
|
|
394
403
|
end
|
395
404
|
|
396
405
|
def threadsafe?
|
397
|
-
jruby_min_runtimes == 1 && jruby_max_runtimes == 1
|
406
|
+
jruby_min_runtimes == 1 && jruby_max_runtimes == 1 # handles [:threadsafe]
|
398
407
|
end
|
399
408
|
|
400
409
|
protected
|
@@ -509,7 +518,7 @@ module Trinidad
|
|
509
518
|
end
|
510
519
|
|
511
520
|
def logger
|
512
|
-
@logger ||=
|
521
|
+
@logger ||= Logging::LogFactory.getLog('')
|
513
522
|
end
|
514
523
|
|
515
524
|
protected
|
@@ -638,7 +647,7 @@ module Trinidad
|
|
638
647
|
end
|
639
648
|
|
640
649
|
# Rack web application (looks for a "rackup" *config.ru* file).
|
641
|
-
class
|
650
|
+
class RackWebApp < WebApp
|
642
651
|
|
643
652
|
def context_params
|
644
653
|
add_context_param 'app.root', app_root
|
@@ -655,6 +664,7 @@ module Trinidad
|
|
655
664
|
def web_xml_environment; web_xml_context_param('rack.env'); end
|
656
665
|
|
657
666
|
end
|
667
|
+
RackupWebApp = RackWebApp
|
658
668
|
|
659
669
|
# Rails web application specifics (supports same versions as JRuby-Rack).
|
660
670
|
class RailsWebApp < WebApp
|
@@ -694,8 +704,8 @@ module Trinidad
|
|
694
704
|
def self.threadsafe_match?(file)
|
695
705
|
File.exist?(file) && (
|
696
706
|
file_line_match?(file, /^[^#]*threadsafe!/) || ( # Rails 4.0
|
697
|
-
file_line_match?(file, /^[^#]*config\.eager_load
|
698
|
-
file_line_match?(file, /^[^#]*config\.cache_classes
|
707
|
+
file_line_match?(file, /^[^#]*config\.eager_load\s?*=\s?*true/) &&
|
708
|
+
file_line_match?(file, /^[^#]*config\.cache_classes\s?*=\s?*true/)
|
699
709
|
)
|
700
710
|
)
|
701
711
|
end
|
@@ -715,7 +725,7 @@ module Trinidad
|
|
715
725
|
def context_path
|
716
726
|
@path ||= begin
|
717
727
|
path = File.basename(super)
|
718
|
-
context_name =
|
728
|
+
context_name = Tomcat::ContextName.new(path)
|
719
729
|
context_name.path # removes .war handles ## versioning
|
720
730
|
end
|
721
731
|
end
|
@@ -751,12 +761,14 @@ module Trinidad
|
|
751
761
|
warbler? ? super : @context_params ||= {}
|
752
762
|
end
|
753
763
|
|
764
|
+
def context_manager; nil end
|
765
|
+
|
754
766
|
def layout_class
|
755
767
|
'JRuby::Rack::WebInfLayout'
|
756
768
|
end
|
757
769
|
|
758
770
|
def define_lifecycle
|
759
|
-
|
771
|
+
Lifecycle::WebApp::War.new(self)
|
760
772
|
end
|
761
773
|
|
762
774
|
private
|
data/trinidad.gemspec
CHANGED
@@ -10,9 +10,10 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.description = "Trinidad allows you to run Rails or Rack applications within " <<
|
11
11
|
"an embedded Apache Tomcat container. Serves your requests with the elegance of a cat !"
|
12
12
|
|
13
|
-
gem.authors = [
|
13
|
+
gem.authors = ['David Calavera']
|
14
14
|
gem.email = 'calavera@apache.org'
|
15
|
-
gem.homepage = '
|
15
|
+
gem.homepage = 'https://github.com/trinidad/trinidad'
|
16
|
+
gem.licenses = ['MIT', 'Apache-2.0']
|
16
17
|
|
17
18
|
gem.require_paths = %w[lib]
|
18
19
|
gem.executables = ["trinidad"]
|
@@ -21,11 +22,11 @@ Gem::Specification.new do |gem|
|
|
21
22
|
gem.rdoc_options = ["--charset=UTF-8"]
|
22
23
|
gem.extra_rdoc_files = %w[README.md LICENSE]
|
23
24
|
|
24
|
-
gem.add_dependency('trinidad_jars',
|
25
|
-
gem.add_dependency('jruby-rack',
|
25
|
+
gem.add_dependency('trinidad_jars', '>= 1.3.0', '< 1.5.0')
|
26
|
+
gem.add_dependency('jruby-rack', '~> 1.1.13')
|
26
27
|
|
27
28
|
gem.add_development_dependency('rake')
|
28
|
-
gem.add_development_dependency('rspec', '~> 2.
|
29
|
+
gem.add_development_dependency('rspec', '~> 2.14.1')
|
29
30
|
gem.add_development_dependency('mocha', '~> 0.12.1')
|
30
31
|
gem.add_development_dependency('fakefs', '>= 0.4.0')
|
31
32
|
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trinidad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
5
|
-
prerelease:
|
4
|
+
version: 1.4.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- David Calavera
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-28 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: trinidad_jars
|
@@ -17,30 +16,32 @@ dependencies:
|
|
17
16
|
requirements:
|
18
17
|
- - '>='
|
19
18
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.
|
21
|
-
|
19
|
+
version: 1.3.0
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.0
|
22
23
|
requirement: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - '>='
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
27
|
-
|
27
|
+
version: 1.3.0
|
28
|
+
- - <
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.5.0
|
28
31
|
prerelease: false
|
29
32
|
type: :runtime
|
30
33
|
- !ruby/object:Gem::Dependency
|
31
34
|
name: jruby-rack
|
32
35
|
version_requirements: !ruby/object:Gem::Requirement
|
33
36
|
requirements:
|
34
|
-
- -
|
37
|
+
- - ~>
|
35
38
|
- !ruby/object:Gem::Version
|
36
39
|
version: 1.1.13
|
37
|
-
none: false
|
38
40
|
requirement: !ruby/object:Gem::Requirement
|
39
41
|
requirements:
|
40
|
-
- -
|
42
|
+
- - ~>
|
41
43
|
- !ruby/object:Gem::Version
|
42
44
|
version: 1.1.13
|
43
|
-
none: false
|
44
45
|
prerelease: false
|
45
46
|
type: :runtime
|
46
47
|
- !ruby/object:Gem::Dependency
|
@@ -50,13 +51,11 @@ dependencies:
|
|
50
51
|
- - '>='
|
51
52
|
- !ruby/object:Gem::Version
|
52
53
|
version: '0'
|
53
|
-
none: false
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
56
|
- - '>='
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
|
-
none: false
|
60
59
|
prerelease: false
|
61
60
|
type: :development
|
62
61
|
- !ruby/object:Gem::Dependency
|
@@ -65,14 +64,12 @@ dependencies:
|
|
65
64
|
requirements:
|
66
65
|
- - ~>
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
69
|
-
none: false
|
67
|
+
version: 2.14.1
|
70
68
|
requirement: !ruby/object:Gem::Requirement
|
71
69
|
requirements:
|
72
70
|
- - ~>
|
73
71
|
- !ruby/object:Gem::Version
|
74
|
-
version: 2.
|
75
|
-
none: false
|
72
|
+
version: 2.14.1
|
76
73
|
prerelease: false
|
77
74
|
type: :development
|
78
75
|
- !ruby/object:Gem::Dependency
|
@@ -82,13 +79,11 @@ dependencies:
|
|
82
79
|
- - ~>
|
83
80
|
- !ruby/object:Gem::Version
|
84
81
|
version: 0.12.1
|
85
|
-
none: false
|
86
82
|
requirement: !ruby/object:Gem::Requirement
|
87
83
|
requirements:
|
88
84
|
- - ~>
|
89
85
|
- !ruby/object:Gem::Version
|
90
86
|
version: 0.12.1
|
91
|
-
none: false
|
92
87
|
prerelease: false
|
93
88
|
type: :development
|
94
89
|
- !ruby/object:Gem::Dependency
|
@@ -98,13 +93,11 @@ dependencies:
|
|
98
93
|
- - '>='
|
99
94
|
- !ruby/object:Gem::Version
|
100
95
|
version: 0.4.0
|
101
|
-
none: false
|
102
96
|
requirement: !ruby/object:Gem::Requirement
|
103
97
|
requirements:
|
104
98
|
- - '>='
|
105
99
|
- !ruby/object:Gem::Version
|
106
100
|
version: 0.4.0
|
107
|
-
none: false
|
108
101
|
prerelease: false
|
109
102
|
type: :development
|
110
103
|
description: Trinidad allows you to run Rails or Rack applications within an embedded Apache Tomcat container. Serves your requests with the elegance of a cat !
|
@@ -141,8 +134,11 @@ files:
|
|
141
134
|
- lib/trinidad/web_app.rb
|
142
135
|
- rakelib/tomcat.rake
|
143
136
|
- trinidad.gemspec
|
144
|
-
homepage:
|
145
|
-
licenses:
|
137
|
+
homepage: https://github.com/trinidad/trinidad
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
- Apache-2.0
|
141
|
+
metadata: {}
|
146
142
|
post_install_message:
|
147
143
|
rdoc_options:
|
148
144
|
- --charset=UTF-8
|
@@ -152,24 +148,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
148
|
requirements:
|
153
149
|
- - '>='
|
154
150
|
- !ruby/object:Gem::Version
|
155
|
-
segments:
|
156
|
-
- 0
|
157
151
|
version: '0'
|
158
|
-
hash: 2
|
159
|
-
none: false
|
160
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
153
|
requirements:
|
162
154
|
- - '>='
|
163
155
|
- !ruby/object:Gem::Version
|
164
|
-
segments:
|
165
|
-
- 0
|
166
156
|
version: '0'
|
167
|
-
hash: 2
|
168
|
-
none: false
|
169
157
|
requirements: []
|
170
158
|
rubyforge_project:
|
171
|
-
rubygems_version: 1.
|
159
|
+
rubygems_version: 2.1.9
|
172
160
|
signing_key:
|
173
|
-
specification_version:
|
161
|
+
specification_version: 4
|
174
162
|
summary: Web server for Rails/Rack applications built upon JRuby::Rack and Apache Tomcat
|
175
163
|
test_files: []
|