Class: JettyRails::Handler::WebAppHandler

Inherits:
Jetty::Handler::WebAppContext
  • Object
show all
Defined in:
lib/jetty_rails/handler/web_app_handler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ WebAppHandler

Returns a new instance of WebAppHandler.


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jetty_rails/handler/web_app_handler.rb', line 6

def initialize(config)
  super("/", config[:context_path])
  @config = config

  self.class_loader = each_context_has_its_own_classloader
  self.resource_base = "#{config[:base]}/public"
  self.descriptor = config[:web_xml]
  
  add_classes_dir_to_classpath(config)
  add_lib_dir_jars_to_classpath(config)
  
  @adapter = adapter_for(config[:adapter])
  self.init_params = @adapter.init_params
  
  unless File.exist?(self.descriptor)
    @adapter.event_listeners.each do |listener|
      add_event_listener(listener)
    end

    add_filter(rack_filter, "/*", Jetty::Context::DEFAULT)
  end
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter


4
5
6
# File 'lib/jetty_rails/handler/web_app_handler.rb', line 4

def adapter
  @adapter
end

#configObject (readonly)

Returns the value of attribute config


4
5
6
# File 'lib/jetty_rails/handler/web_app_handler.rb', line 4

def config
  @config
end

Class Method Details

.adaptersObject


33
34
35
36
37
38
39
# File 'lib/jetty_rails/handler/web_app_handler.rb', line 33

def self.adapters
  @adapters ||= {
    :rails => JettyRails::Adapters::RailsAdapter,
    :rails_jms => JettyRails::Adapters::RailsJmsAdapter,
    :merb => JettyRails::Adapters::MerbAdapter
  }
end

.add_adapter(adapter_key, adapter) ⇒ Object


29
30
31
# File 'lib/jetty_rails/handler/web_app_handler.rb', line 29

def self.add_adapter(adapter_key, adapter)
  adapters[adapter_key] = adapter
end

Instance Method Details

#adaptersObject


41
42
43
# File 'lib/jetty_rails/handler/web_app_handler.rb', line 41

def adapters
  self.class.adapters
end

#get_from_public_otherwiseObject


45
# File 'lib/jetty_rails/handler/web_app_handler.rb', line 45

alias :get_from_public_otherwise :getResource

#getResource(resource) ⇒ Object


47
48
49
50
# File 'lib/jetty_rails/handler/web_app_handler.rb', line 47

def getResource(resource)
  return fix_for_base_url if resource == '/'
  get_from_public_otherwise resource
end