Class: RBoss::JBossWeb

Inherits:
Object
  • Object
show all
Includes:
Component
Defined in:
lib/rboss/components/jbossweb.rb

Instance Method Summary collapse

Methods included from Component

#configure, #initialize, #load_yaml, #new_file_processor

Instance Method Details

#configure_connector(attributes, defaults) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/rboss/components/jbossweb.rb', line 96

def configure_connector attributes, defaults
  @actions << lambda do |xml, jboss|
    tag = XPath.first xml, "//Connector[@protocol='#{defaults[:protocol]}'][@port='#{defaults[:port]}']"
    unless tag
      tag = Element::new "Connector"
      xml.insert_after "//Connector", tag
    end
    attributes.each do |key, value|
      key = key.to_s.camelize.uncapitalize if key.is_a? Symbol
      tag.attributes[key] = value.to_s
    end
    xml
  end
end

#configure_connectorsObject



87
88
89
90
91
92
93
94
# File 'lib/rboss/components/jbossweb.rb', line 87

def configure_connectors
  @config[:connectors].each do |type, attributes|
    defaults = connector_defaults[type.to_sym]
    defaults ||= connector_defaults[:other]
    attributes = defaults.merge attributes
    configure_connector attributes, defaults
  end
end

#configure_engineObject



111
112
113
114
115
116
117
# File 'lib/rboss/components/jbossweb.rb', line 111

def configure_engine
  @actions << lambda do |xml, jboss|
    engine = XPath.first xml, "//Engine[@name='jboss.web']"
    engine.attributes["jvmRoute"] = @config[:jvm_route]
    xml
  end
end

#connector_defaultsObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rboss/components/jbossweb.rb', line 40

def connector_defaults
  {
    :http => {
      :address => "${jboss.bind.address}",
      :protocol => "HTTP/1.1",
      :port => 8080
    },
    :ajp => {
      :address => "${jboss.bind.address}",
      :protocol => "AJP/1.3",
      :port => 8009,
      :redirect_port => 8443
    },
    :https => {
      :addres => "${jboss.bind.address}",
      :port => 8443,
      :protocol => "HTTP/1.1",
      :scheme => "https",
      'SSLEnabled' => true,
      :secure => true,
      :ssl_protocol => "TLS",
      :client_auth => false,
      :keystore_file => '${jboss.server.home.dir}/conf/.keystore'
    },
    :other => {
      :address => "${jboss.bind.address}",
      :protocol => "HTTP/1.1"
    }
  }
end

#defaultsObject



33
34
35
36
37
38
# File 'lib/rboss/components/jbossweb.rb', line 33

def defaults
  {
    :connectors => [],
    :jvm_route => nil
  }
end

#processObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/rboss/components/jbossweb.rb', line 71

def process
  @processor = new_file_processor
  @actions = []
  configure_connectors
  configure_engine if @config[:jvm_route]
  @processor.with "#{@jboss.profile}/deploy/jbossweb.sar/server.xml", :xml do |action|
    action.to_process do |xml, jboss|
      @actions.each do |block|
        xml = block.call(xml, jboss)
      end
      xml
    end
  end
  @processor.process
end