Class: Rack::Handler::Jetty

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/handler/jetty.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Jetty

Returns a new instance of Jetty.



10
11
12
13
# File 'lib/rack/handler/jetty.rb', line 10

def initialize(app, options={})
  @app = app
  @options = options
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



7
8
9
# File 'lib/rack/handler/jetty.rb', line 7

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/rack/handler/jetty.rb', line 8

def options
  @options
end

Class Method Details

.run(app, options = {}) ⇒ Object



15
16
17
# File 'lib/rack/handler/jetty.rb', line 15

def self.run(app, options = {})
  new(app,options).run()
end

Instance Method Details

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rack/handler/jetty.rb', line 19

def run()
  @connector = Java::org.mortbay.jetty.bio.SocketConnector.new
  @connector.set_host(options[:Host])
  @connector.set_port(options[:Port].to_i)

  @jetty = Java::org.mortbay.jetty.Server.new
  @jetty.addConnector(@connector)
  
  bridge = RackJetty::ServletHandler.new
  bridge.handler = self
  
  @jetty.set_handler(bridge)
  @jetty.start
end

#running?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/rack/handler/jetty.rb', line 34

def running?
  @jetty && @jetty.is_started
end

#stopObject



42
43
44
# File 'lib/rack/handler/jetty.rb', line 42

def stop()
  @jetty && @jetty.stop
end

#stopped?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/rack/handler/jetty.rb', line 38

def stopped?
  !@jetty || @jetty.is_stopped
end