Class: RBoss::ModCluster

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

Overview

A class to install and configure a mod_cluster service in a JBoss profile

Configuration:

:path => where the mod_cluster.sar is located :folder => where the mod_cluster.sar should be installed (default: $JBOSS_HOME/server/$CONFIG/deploy)

The additional configurations are the entries in the bean ModClusterConfig (mod_cluster-jboss-beans.xml) and can be in a String form (using the entry name) or in a Symbol form (using ruby nomenclature - :sticky_session)

author: Marcelo Guimarães <[email protected]>

Instance Method Summary collapse

Methods included from Component

#initialize, #load_yaml, #new_file_processor

Instance Method Details

#configure(config) ⇒ Object



50
51
52
53
54
# File 'lib/rboss/components/mod_cluster.rb', line 50

def configure config
  @path = config.delete :path
  @folder = config.delete :folder
  @config = config
end

#defaultsObject



46
47
48
# File 'lib/rboss/components/mod_cluster.rb', line 46

def defaults
  {:folder => "#{@jboss.profile}/deploy"}
end

#processObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/rboss/components/mod_cluster.rb', line 56

def process
  @logger.info "Installing mod_cluster.sar"
  cp_r @path, @folder

  return if @config.empty?

  @logger.info "Configuring mod_cluster.sar"
  processor = new_file_processor
  processor.with "#{@folder}/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml", :xml do |action|
    action.to_process do |xml, jboss|
      config = XPath.first(xml, "//bean[@name='ModClusterConfig']")
      @config.each do |property, value|
        element = XPath.first config, "property[@name='#{property.to_s.camelize.uncapitalize}']"
        if element
          @logger.debug "Configuring #{element.attribute('name').value} to \"#{value}\""
          element.text = value
        end
      end
      xml
    end
  end
  processor.process
end