lib/trinidad/server.rb in trinidad-0.9.1 vs lib/trinidad/server.rb in trinidad-0.9.2
- old
+ new
@@ -71,11 +71,11 @@
opts.each do |key, value|
connector.setProperty(key.to_s, value.to_s)
end
- @tomcat.getService().addConnector(connector)
+ @tomcat.service.add_connector(connector)
connector
end
def add_ajp_connector
add_service_connector(@config[:ajp], 'AJP/1.3')
@@ -85,15 +85,18 @@
options = @config[:ssl].merge({
:scheme => 'https',
:secure => true,
:SSLEnabled => 'true'
})
- options[:keystore] ||= 'ssl/keystore'
- options[:keystorePass] ||= 'waduswadus'
+ if !options[:keystore] && !options[:SSLCertificateFile]
+ options[:keystore] = 'ssl/keystore'
+ options[:keystorePass] = 'waduswadus'
+ end
+
add_service_connector(options)
- create_default_keystore(options) unless File.exist?(options[:keystore])
+ create_default_keystore(options)
end
def add_http_connector
options = @config[:http]
options[:port] = @config[:port]
@@ -114,14 +117,16 @@
def http_configured?
@config.has_key?(:http)
end
def create_default_keystore(config)
+ return if !config[:keystore] || File.exist?(config[:keystore])
+
keystore_file = java.io.File.new(config[:keystore])
- if (!keystore_file.parent_file.exists() &&
- !keystore_file.parent_file.mkdir())
+ if (!keystore_file.parent_file.exists &&
+ !keystore_file.parent_file.mkdir)
raise "Unable to create keystore folder: " + keystore_file.parent_file.canonical_path
end
keytool_args = ["-genkey",
"-alias", "localhost",
@@ -136,11 +141,11 @@
Trinidad::Tomcat::KeyTool.main(keytool_args.to_java(:string))
end
def start
@tomcat.start
- @tomcat.getServer().await
+ @tomcat.server.await
end
private
def add_default_web_app!(config)
@@ -154,22 +159,22 @@
config[:web_apps] = { :default => default_app }
end
end
def enable_naming
- @tomcat.getServer().addLifecycleListener(Trinidad::Tomcat::NamingContextListener.new)
+ @tomcat.server.add_lifecycle_listener(Trinidad::Tomcat::NamingContextListener.new)
- JSystem.setProperty("catalina.useNaming", "true")
+ JSystem.set_property("catalina.useNaming", "true")
value = "org.apache.naming"
- old_value = JSystem.getProperty(JContext.URL_PKG_PREFIXES) || value
+ old_value = JSystem.get_property(JContext::URL_PKG_PREFIXES) || value
value = value + ":" + old_value unless old_value.include?(value)
- JSystem.setProperty(JContext.URL_PKG_PREFIXES, value)
+ JSystem.set_property(JContext::URL_PKG_PREFIXES, value)
- value = JSystem.getProperty(JContext.INITIAL_CONTEXT_FACTORY)
+ value = JSystem.get_property(JContext::INITIAL_CONTEXT_FACTORY)
unless value
- JSystem.setProperty(JContext.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory")
+ JSystem.set_property(JContext::INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory")
end
end
def remove_defaults(app_context)
default_servlet = app_context.find_child('default')