lib/trinidad/server.rb in trinidad-0.8.3 vs lib/trinidad/server.rb in trinidad-0.9.0

- old
+ new

@@ -29,35 +29,36 @@ add_default_web_app!(@config) end def load_tomcat_server @tomcat = Trinidad::Tomcat::Tomcat.new - @tomcat.setPort(@config[:port].to_i) - @tomcat.setBaseDir(Dir.pwd) + @tomcat.port = @config[:port].to_i + @tomcat.base_dir = Dir.pwd + @tomcat.host.app_base = Dir.pwd enable_naming add_ssl_connector if ssl_enabled? add_ajp_connector if ajp_enabled? @tomcat = Trinidad::Extensions.configure_server_extensions(@config[:extensions], @tomcat) end def create_web_apps - @config[:web_apps].each do |name, app| - app[:context_path] ||= (name.to_s == 'default' ? '/' : "/#{name.to_s}") - app[:web_app_dir] ||= Dir.pwd + @config[:web_apps].each do |name, app_config| + app_config[:context_path] ||= (name.to_s == 'default' ? '/' : "/#{name.to_s}") + app_config[:web_app_dir] ||= Dir.pwd - tomcat_app = @tomcat.addWebapp(app[:context_path].to_s, app[:web_app_dir]) + app_context = @tomcat.addWebapp(app_config[:context_path], app_config[:web_app_dir]) + remove_defaults(app_context) - web_app = WebApp.create(tomcat_app, @config, app) + web_app = WebApp.create(app_context, @config, app_config) web_app.load_default_web_xml - web_app.add_rack_filter + web_app.configure_rack web_app.configure_extensions(@tomcat) web_app.add_context_loader web_app.add_init_params - web_app.add_web_dir_resources web_app.add_rack_context_listener end end @@ -155,8 +156,16 @@ value = JSystem.getProperty(JContext.INITIAL_CONTEXT_FACTORY) unless value JSystem.setProperty(JContext.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory") end + end + + def remove_defaults(app_context) + default_servlet = app_context.find_child('default') + app_context.remove_child(default_servlet) if default_servlet + + jsp_servlet = app_context.find_child('jsp') + app_context.remove_child(jsp_servlet) if jsp_servlet end end end