lib/trinidad/web_app.rb in trinidad-1.5.0.B1 vs lib/trinidad/web_app.rb in trinidad-1.5.0.B2
- old
+ new
@@ -32,23 +32,25 @@
key = key.to_sym
return true if config.has_key?(key)
use_default ? default_config.key?(key) : false
end
- %w{ root_dir rackup async_supported reload_strategy host_name }.each do
- |method| class_eval "def #{method}; self[:'#{method}']; end"
- end
+ def root_dir; self[:root_dir] end
+ def rackup; self[:rackup] end
+ def host_name; self[:host_name] end
+ def async_supported; self[:async_supported] end
+ def reload_strategy; self[:reload_strategy] end
alias_method :web_app_dir, :root_dir # is getting deprecated soon
def app_root; root_dir; end
# @deprecated use `self[:log]` instead
def log; self[:log]; end
def context_path
path = self[:context_path] || self[:path]
- path ? path.to_s : path
+ path ? path.to_s : path #
end
def context_name
name = self[:context_name] || self[:name]
name ? name.to_s : name
@@ -90,11 +92,13 @@
def jruby_runtime_acquire_timeout
fetch_config_value(:jruby_runtime_acquire_timeout, 5.0) # default 10s seems too high
end
def jruby_compat_version
- fetch_config_value(:jruby_compat_version, RUBY_VERSION)
+ compat_version = fetch_config_value(:jruby_compat_version, false)
+ return compat_version unless compat_version.eql? false
+ JRUBY_VERSION < '9.0' ? RUBY_VERSION[0, 3] : nil
end
def environment
@environment ||= begin
if env = web_xml_environment
@@ -171,24 +175,25 @@
add_context_param 'jruby.max.runtimes', jruby_max_runtimes
unless threadsafe?
add_context_param 'jruby.initial.runtimes', jruby_initial_runtimes
add_context_param 'jruby.runtime.acquire.timeout', jruby_runtime_acquire_timeout
end
- add_context_param 'jruby.compat.version', jruby_compat_version
+ if compat_version = jruby_compat_version
+ add_context_param 'jruby.compat.version', compat_version
+ end
add_context_param 'public.root', public_root
add_context_param 'jruby.rack.layout_class', layout_class
# JRuby::Rack::ErrorApp got a bit smarter so use it, TODO maybe override ?
add_context_param 'jruby.rack.error', false # do not start error app on errors
@context_params
end
# @deprecated replaced with {#context_params}
def init_params; context_params; end
def add_context_param(param_name, param_value)
- @context_params ||= {}
if ! param_value.nil? && ! web_xml_context_param(param_name)
- @context_params[param_name] = param_value.to_s
+ (@context_params ||= {})[param_name] = param_value.to_s
end
end
# TODO: internal API - should be configurable/adjustable with context.yml !
def context_manager; Java::RbTrinidadContext::DefaultManager.new end
@@ -420,11 +425,11 @@
config[:root_dir] = File.expand_path(config[:root_dir])
config[:context_path] = self.class.context_path(config, default_config)
return if key?(:jruby_max_runtimes) || key?(:jruby_min_runtimes)
- if ( ! key?(:threadsafe) && ! detect_threadsafe? ) || self[:threadsafe] == false
+ if key?(:threadsafe) && self[:threadsafe] == false
max_runtimes = config[:jruby_max_runtimes] = guess_max_runtimes
if environment == 'development' || environment == 'test'
config[:jruby_min_runtimes] = 1
else
config[:jruby_min_runtimes] = max_runtimes
@@ -432,10 +437,11 @@
else
config[:jruby_min_runtimes] = config[:jruby_max_runtimes] = 1
end
end
+ # @deprecated no longer used
def detect_threadsafe?(environment = self.environment); true end
def guess_max_runtimes; 5 end
public
@@ -588,12 +594,11 @@
unless path
name = config[:context_name] ||
( default_config && default_config[:context_name] )
path = name.to_s == 'default' ? '/' : "/#{name}"
end
- path = "/#{path}" if path.to_s[0, 1] != '/'
- path.to_s
+ path.to_s[0, 1] != '/' ? "/#{path}" : path.to_s
end
private
def file_line_match?(path, pattern = nil)
@@ -670,9 +675,10 @@
protected
# NOTE: maybe we can guess these based on connector maxThreads?
# def guess_max_runtimes; 5 end
+ # @deprecated no longer used
def detect_threadsafe?(environment = self.environment)
if environment == 'development' || environment == 'test'
# NOTE: it's best for development/test to use the same setup as in
# production by default, thread-safe likely won't be detected as :
#