Class: Hobix::WebApp::WEBrickServletHandler
- Inherits:
-
Object
- Object
- Hobix::WebApp::WEBrickServletHandler
- Defined in:
- lib/hobix/webapp/webrick-servlet.rb
Constant Summary collapse
- LoadedServlets =
{}
Class Method Summary collapse
- .get_instance(config, name) ⇒ Object
-
.load_servlet(path) ⇒ Object
load a WEBrick servlet written using webapp.
Class Method Details
.get_instance(config, name) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/hobix/webapp/webrick-servlet.rb', line 42 def WEBrickServletHandler.get_instance(config, name) unless LoadedServlets[name] LoadedServlets[name] = load_servlet(name) end LoadedServlets[name] end |
.load_servlet(path) ⇒ Object
load a WEBrick servlet written using webapp. WEBrickServletHandler.load_servlet returns a WEBrick servlet generated by WEBrick::HTTPServlet::ProcHandler.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hobix/webapp/webrick-servlet.rb', line 52 def WEBrickServletHandler.load_servlet(path) begin Thread.current[:webrick_load_servlet] = true load path, true unless Thread.current[:webrick_load_servlet].respond_to? :call raise "WEBrick servlet is not registered: #{path}" end procedure = Thread.current[:webrick_load_servlet] return WEBrick::HTTPServlet::ProcHandler.new(procedure) ensure Thread.current[:webrick_load_servlet] = nil end end |