Class: Rubylet::WebappDescriptorBuilder

Inherits:
Builder::XmlMarkup
  • Object
show all
Extended by:
BuilderAliasTag
Includes:
BuilderDefaults
Defined in:
lib/rubylet/webapp_descriptor_builder.rb

Instance Method Summary collapse

Methods included from BuilderAliasTag

alias_tag

Methods included from BuilderDefaults

#initialize

Instance Method Details

#context_param!(name, value) ⇒ Object

Write a context param tag unless value is nil.



47
48
49
50
51
52
53
# File 'lib/rubylet/webapp_descriptor_builder.rb', line 47

def context_param!(name, value)
  return unless value
  context_param { |p|
    p.param_name name
    p.param_value value
  }
end

#init_param!(name, value) ⇒ Object

Write an init param tag unless value is nil.



56
57
58
59
60
61
62
# File 'lib/rubylet/webapp_descriptor_builder.rb', line 56

def init_param!(name, value)
  return unless value
  init_param { |p|
    p.param_name name
    p.param_value value
  }
end

#listener!(klass) ⇒ Object



64
65
66
# File 'lib/rubylet/webapp_descriptor_builder.rb', line 64

def listener!(klass)
  listener { |w| w.listener_class(klass) }
end

#web_app!(version, metadata_complete = true, &block) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/rubylet/webapp_descriptor_builder.rb', line 68

def web_app!(version,  = true, &block)
  xmlns, schema_loc =
    case version.to_s
    when '2.5'
      j2ee = 'http://java.sun.com/xml/ns/j2ee'
      [j2ee, "#{j2ee}/web-app_2_5.xsd"]
    when '3.0'
      javaee = 'http://java.sun.com/xml/ns/javaee'
      [javaee, "#{javaee} #{javaee}/web-app_3_0.xsd"]
    else
      raise ArgumentError, "unknown java servlet version #{version}"
    end
  
  web_app('xmlns' => xmlns,
          'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
          'xsi:schemaLocation' => schema_loc,
          'version' => version.to_s,
          'metadata-complete' => ,
          &block)
end