rboss 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/.gitignore +9 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +1 -0
  4. data/bin/jboss-profile +90 -0
  5. data/bin/twiddle +230 -0
  6. data/examples/jboss_profile/jbb_profile_1.yaml +32 -0
  7. data/examples/jboss_profile/jbb_profile_2.yaml +32 -0
  8. data/examples/jboss_profile/jboss_profile.yaml +7 -0
  9. data/examples/monitor/simple_monitor.rb +61 -0
  10. data/lib/rboss.rb +25 -0
  11. data/lib/rboss/component_processor.rb +177 -0
  12. data/lib/rboss/components/component.rb +52 -0
  13. data/lib/rboss/components/datasource.rb +198 -0
  14. data/lib/rboss/components/deploy_folder.rb +104 -0
  15. data/lib/rboss/components/hypersonic_replacer.rb +58 -0
  16. data/lib/rboss/components/jbossweb.rb +117 -0
  17. data/lib/rboss/components/jmx.rb +88 -0
  18. data/lib/rboss/components/mod_cluster.rb +81 -0
  19. data/lib/rboss/components/org/6.0/deploy_folder.rb +33 -0
  20. data/lib/rboss/components/org/jmx.rb +59 -0
  21. data/lib/rboss/components/profile_folder.rb +44 -0
  22. data/lib/rboss/components/resource.rb +53 -0
  23. data/lib/rboss/components/run_conf.rb +90 -0
  24. data/lib/rboss/components/run_conf.yaml +22 -0
  25. data/lib/rboss/components/service_script.rb +55 -0
  26. data/lib/rboss/components/slimming.rb +124 -0
  27. data/lib/rboss/components/soa-p/hypersonic_replacer.rb +79 -0
  28. data/lib/rboss/components/soa-p/jmx.rb +47 -0
  29. data/lib/rboss/components/xadatasource.rb +67 -0
  30. data/lib/rboss/file_processor.rb +107 -0
  31. data/lib/rboss/jboss_path.rb +53 -0
  32. data/lib/rboss/jboss_profile.rb +344 -0
  33. data/lib/rboss/resources/jboss_init_redhat.sh.erb +140 -0
  34. data/lib/rboss/resources/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml +282 -0
  35. data/lib/rboss/resources/mod_cluster.sar/mod_cluster-1.1.2.Final.jar +0 -0
  36. data/lib/rboss/resources/run.conf.erb +62 -0
  37. data/lib/rboss/twiddle.rb +25 -0
  38. data/lib/rboss/twiddle/base_monitor.rb +57 -0
  39. data/lib/rboss/twiddle/mbean.rb +82 -0
  40. data/lib/rboss/twiddle/monitor.rb +144 -0
  41. data/lib/rboss/twiddle/scanner.rb +92 -0
  42. data/lib/rboss/twiddle/twiddle.rb +71 -0
  43. data/lib/rboss/utils.rb +33 -0
  44. data/lib/rboss/version.rb +25 -0
  45. data/rboss.gemspec +20 -0
  46. data/test/datasource_test.rb +211 -0
  47. data/test/deploy_folder_test.rb +126 -0
  48. data/test/mbean_test.rb +53 -0
  49. data/test/test_helper.rb +124 -0
  50. data/test/test_suite.rb +35 -0
  51. metadata +109 -0
@@ -0,0 +1,79 @@
1
+ # The MIT License
2
+ #
3
+ # Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require 'fileutils'
24
+
25
+ module JBoss
26
+
27
+ # A class to replace Hypersonic in SOA-P. This class makes a build.properties file
28
+ # and calls the ant script present in $JBOSS_HOME/tools/schema/build.xml since this
29
+ # script does everything we need to replace Hypersonic.
30
+ #
31
+ # The configuration must be in a form key => value and the keys needs to be
32
+ # in the $JBOSS_HOME/tools/schema/build.properties file.
33
+ #
34
+ # The ant script minimal keys are:
35
+ # - db.name
36
+ # - db.hostname
37
+ # - db.port
38
+ # - db.username
39
+ # - db.password
40
+ # - source.dir (the directory in $JBOSS_HOME/tools/schema/ that matches the database type)
41
+ #
42
+ # author: Marcelo Guimarães <ataxexe@gmail.com>
43
+ class HypersonicReplacer
44
+ include FileUtils
45
+
46
+ def defaults
47
+ {
48
+ "org.jboss.esb.server.home" => File.expand_path(@jboss.home),
49
+ "org.jboss.esb.server.clustered" => "#{File.exists? "#{@jboss.profile}/farm"}",
50
+ "org.jboss.esb.server.config" => "#{@jboss.profile_name}",
51
+
52
+ "db.minpoolsize" => 15,
53
+ "db.maxpoolsize" => 50
54
+ }
55
+ end
56
+
57
+ def configure config
58
+ @config = config
59
+ end
60
+
61
+ def process
62
+ properties = @config.collect { |key, value| "#{key} = #{value}" }
63
+
64
+ # make a backup of build.properties
65
+ mv "#{@jboss.home}/tools/schema/build.properties", "#{@jboss.home}/tools/schema/build.properties~"
66
+
67
+ File.open("#{@jboss.home}/tools/schema/build.properties", 'w+') { |f| f.write properties.join("\n") }
68
+
69
+ cd "#{@jboss.home}/tools/schema" do
70
+ @logger.info "Executing ant..."
71
+ `ant`
72
+ end
73
+
74
+ mv "#{@jboss.home}/tools/schema/build.properties~", "#{@jboss.home}/tools/schema/build.properties"
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,47 @@
1
+ # The MIT License
2
+ #
3
+ # Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ # A class that extends the default JMX component
24
+ # for compatibillity with JBoss SOA-P
25
+ #
26
+ # author: Marcelo Guimarães <ataxexe@gmail.com>
27
+ module JBoss
28
+ class JMX
29
+
30
+ def defaults
31
+ {
32
+ :user => "admin",
33
+ :password => "admin",
34
+ :roles => "JBossAdmin,HttpInvoker,admin,user"
35
+ }
36
+ end
37
+
38
+ def users_properties_file
39
+ "soa-users.properties"
40
+ end
41
+
42
+ def roles_properties_file
43
+ "soa-roles.properties"
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,67 @@
1
+ # The MIT License
2
+ #
3
+ # Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require_relative "datasource"
24
+ require_relative "component"
25
+
26
+ require "logger"
27
+ require "rexml/document"
28
+
29
+ include REXML
30
+
31
+ module JBoss
32
+
33
+ # A class to configure a JBoss XADatasource.
34
+ #
35
+ # The configuration will change a <xa-datasource-property> value.
36
+ #
37
+ # Configuration attributes are the same as for a JBoss::Datasource
38
+ #
39
+ # author: Marcelo Guimarães <ataxexe@gmail.com>
40
+ class XADatasource < Datasource
41
+ include Component
42
+
43
+ def configure config
44
+ super config
45
+ @type << "-xa"
46
+ end
47
+
48
+ def configure_datasource xml
49
+ if @encrypt
50
+ xml.delete_element "//xa-datasource-property[@name='User']"
51
+ xml.delete_element "//xa-datasource-property[@name='Password']"
52
+ @service = "XATxCM"
53
+ end
54
+ @attributes.each do |key, value|
55
+ element = find(xml, key) {|k| "//xa-datasource-property[@name='#{k}']"}
56
+
57
+ if element
58
+ element.text = value
59
+ else
60
+ insert_attribute xml, key, value
61
+ end
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,107 @@
1
+ # The MIT License
2
+ #
3
+ # Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require "rexml/document"
24
+ require "fileutils"
25
+ require "ostruct"
26
+ require "logger"
27
+
28
+ class FileProcessor
29
+
30
+ def initialize opts = {}
31
+ @logger = opts[:logger]
32
+ @var = opts[:var]
33
+ @logger ||= Logger::new(STDOUT)
34
+ @handlers = {
35
+ :plain => {
36
+ :load => lambda do |file|
37
+ @logger.info "Loading file #{file}"
38
+ File.read(file)
39
+ end,
40
+ :store => lambda do |file, content|
41
+ @logger.info "Saving file #{file}"
42
+ File.open(file, 'w+') { |f| f.write (content) }
43
+ end
44
+ },
45
+ :xml => {
46
+ :load => lambda do |file|
47
+ @logger.info "Parsing file #{file}"
48
+ REXML::Document::new File::new(file)
49
+ end,
50
+
51
+ :store => lambda do |file, xml|
52
+ @logger.info "Saving file #{file}"
53
+ content = ''
54
+ formatter = REXML::Formatters::Pretty::new 2
55
+ formatter.write xml, content
56
+ File.open(file, 'w+') { |f| f.write content }
57
+ end
58
+ }
59
+ }
60
+
61
+ @actions = {}
62
+ end
63
+
64
+ def register type, actions
65
+ @handlers[type] = actions
66
+ end
67
+
68
+ def with file, type = :plain
69
+ @current_file = file.to_s
70
+ @actions[@current_file] = {}
71
+ to_load &@handlers[type][:load]
72
+ to_store &@handlers[type][:store]
73
+ yield self
74
+ end
75
+
76
+ def copy_to file
77
+ @actions[@current_file][:copy] = file.to_s
78
+ end
79
+
80
+ def return
81
+ @actions[@current_file][:return] = true
82
+ end
83
+
84
+ def to_load &block
85
+ @actions[@current_file][:to_load] = block
86
+ end
87
+
88
+ def to_store &block
89
+ @actions[@current_file][:to_store] = block
90
+ end
91
+
92
+ def to_process &block
93
+ @actions[@current_file][:to_process] = block
94
+ end
95
+
96
+ def process
97
+ @actions.each do |file, action|
98
+ action[:obj] = action[:to_load].call file
99
+ @logger.info "Processing file #{file}"
100
+ action[:obj] = action[:to_process].call(action[:obj], @var) if action[:obj]
101
+ file = action[:copy] if action[:copy]
102
+ return action[:obj] if action[:return]
103
+ action[:to_store].call file, action[:obj]
104
+ end
105
+ end
106
+
107
+ end
@@ -0,0 +1,53 @@
1
+ # The MIT License
2
+ #
3
+ # Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require "logger"
24
+
25
+ module JBoss
26
+
27
+ # A class that represents the JBoss structure.
28
+ #
29
+ # author Marcelo Guimarães <ataxexe@gmail.com>
30
+ class Path
31
+
32
+ attr_reader :profile, :profile_name, :home, :type, :version
33
+
34
+ def initialize jboss_home, params = {}
35
+ params = {
36
+ :profile => :custom,
37
+ :type => :undefined,
38
+ version => :undefined
39
+ }.merge params
40
+ @home = jboss_home
41
+ @profile ="#{@home}/server/#{params[:profile]}"
42
+ @profile_name = @profile.to_s
43
+ @type = params[:type]
44
+ @version = params[:version]
45
+ end
46
+
47
+ def to_s
48
+ @home
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,344 @@
1
+ # The MIT License
2
+ #
3
+ # Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require_relative "file_processor"
24
+ require_relative "utils"
25
+ require_relative "component_processor"
26
+ require_relative "jboss_path"
27
+
28
+ require "logger"
29
+ require "ostruct"
30
+ require "fileutils"
31
+
32
+ module JBoss
33
+
34
+ # A Class to configure a JBoss Profile
35
+ #
36
+ # Basically, this class is a Component Processor with some components added to configure a JBoss profile, the built-in
37
+ # components are:
38
+ #
39
+ # :deploy_folder => binded to a JBoss::DeployFolder
40
+ #
41
+ # :cluster => a shortcut component for :run_conf, sends these attributes to it:
42
+ # :multicast_ip => default "239.255.0.1"
43
+ # :partition_name => default "${profile name}-partition
44
+ #
45
+ # :jms => a shortcut component for :run_conf, sends these attributes to it:
46
+ # :peer_id
47
+ #
48
+ # :bind => a shortcut component, sends these attributes:
49
+ # To :run_conf
50
+ # :ports => sends as :service_binding
51
+ # To :init_script
52
+ # :address => default "localhost", sends as :bind_address
53
+ #
54
+ # :resource => binded to a JBoss::Resource
55
+ #
56
+ # :jmx => binded to a JBoss::JMX, enabled by default and sends user and password
57
+ # values to :init_script
58
+ #
59
+ # :datasource => binded to a JBoss::Datasource
60
+ #
61
+ # :xa_datasource => binded to a JBoss::XADatasource
62
+ #
63
+ # :default_ds => binded to a JBoss::HypersonicReplacer
64
+ #
65
+ # :mod_cluster => binded to a JBoss::ModCluster
66
+ # Defaults:
67
+ # :path => "resources/mod_cluster.sar"
68
+ # Move to :run_conf (for externalizing mod_cluster configuration)
69
+ # :advertise
70
+ # :advertise_group_address
71
+ # :advertise_port
72
+ # :proxy_list
73
+ # :excluded_contexts
74
+ # :auto_enable_contexts
75
+ #
76
+ # :run_conf => binded to a JBoss::RunConf
77
+ # Defaults:
78
+ # :path => 'resources/run.conf.erb'
79
+ # :stack_size => '128k'
80
+ # :heap_size => '2048m'
81
+ # :perm_size => '256m'
82
+ #
83
+ # :slimming => binded to a JBoss::Slimming
84
+ #
85
+ # :init_script => binded to a JBoss::ServiceScritp
86
+ # Defaults:
87
+ # :path => 'resources/jboss_init_redhat.sh'
88
+ # :jmx_user => "admin"
89
+ # :jmx_password => "admin"
90
+ # :bind_address => "0.0.0.0"
91
+ # :java_path => "/usr/java/default"
92
+ # :jnp_port => 1099
93
+ # :jboss_user => "RUNASIS"
94
+ #
95
+ # author Marcelo Guimarães <ataxexe@gmail.com>
96
+ class Profile < ComponentProcessor
97
+
98
+ # Priorities for components
99
+ @@pre_install = 0
100
+ @@install = @@pre_install + 10
101
+ @@post_install = @@install + 10
102
+
103
+ @@pre_setup = @@post_install + 10
104
+ @@setup = @@pre_setup + 10
105
+ @@post_setup = @@setup + 10
106
+
107
+ @@final = @@post_setup + 10
108
+
109
+ attr_reader :jboss
110
+
111
+ def initialize opts = {}
112
+ block = lambda { |type, config| type.new(@jboss, @logger, config).process }
113
+ super &block
114
+ @base_dir = File.dirname(__FILE__)
115
+ @opts = {
116
+ :jboss_home => ENV['JBOSS_HOME'],
117
+ :base_profile => :production,
118
+ :profile => :custom,
119
+ :type => :undefined,
120
+ :version => :undefined
121
+ }.merge! opts
122
+ @jboss_home = File.expand_path @opts[:jboss_home]
123
+ @logger = @opts[:logger]
124
+ unless @logger
125
+ @logger = Logger::new STDOUT
126
+ @logger.level = opts[:log_level] if opts[:log_level]
127
+ formatter = Logger::Formatter.new
128
+
129
+ def formatter.call(severity, time, program_name, message)
130
+ "#{severity} : #{message}\n"
131
+ end
132
+
133
+ @logger.formatter = formatter
134
+ end
135
+ @profile = @opts[:profile].to_s
136
+ @base_profile = @opts[:base_profile].to_s
137
+ @jboss = JBoss::Path::new @jboss_home,
138
+ :profile => @profile,
139
+ :type => @opts[:type],
140
+ :version => @opts[:version]
141
+ initialize_components
142
+ end
143
+
144
+ def create
145
+ add :profile_folder, @base_profile
146
+ process_components
147
+ end
148
+
149
+ alias update process_components
150
+
151
+ # For making code more readable
152
+ #
153
+ # example: profile.install :mod_cluster
154
+ alias install add
155
+
156
+ # For making code more readable
157
+ #
158
+ # example: profile.configure :jmx, :password => "password"
159
+ alias configure add
160
+
161
+ # For making code more readable
162
+ #
163
+ # example: profile.slim :jmx_console, :admin_console
164
+ def slim *args
165
+ add :slimming, args
166
+ end
167
+
168
+ # loads extensions to components based on the type of jboss (eap, soa-p, org, epp...)
169
+ def load_extensions
170
+ unless @jboss.type == :undefined
171
+ dir = File.join(@base_dir, "components", @jboss.type.to_s.gsub(/_/, '-'))
172
+ load_scripts_in dir
173
+ unless @jboss.version == :undefined
174
+ dir = File.join(dir, @jboss.version.to_s)
175
+ load_scripts_in dir
176
+ end
177
+ end
178
+ end
179
+
180
+ def load_scripts_in dir
181
+ if File.exists? dir
182
+ scripts = Dir.entries(dir).find_all { |f| f.end_with? '.rb' }
183
+ scripts.each do |script|
184
+ load File.join(dir, script)
185
+ end
186
+ end
187
+ end
188
+
189
+ # Loads manually every script related to jboss. This is necessary to reset the components to its natural state
190
+ def load_scripts
191
+ scripts = Dir.entries("#{@base_dir}/components").find_all { |f| f.end_with?('.rb') }
192
+ scripts.each do |script|
193
+ load File.expand_path(@base_dir) + "/components/" + script
194
+ end
195
+ end
196
+
197
+ def initialize_components
198
+ load_scripts
199
+ load_extensions
200
+
201
+ register :cluster,
202
+
203
+ :priority => @@pre_install,
204
+ :move_config => {
205
+ :to_run_conf => [:multicast_ip, :partition_name],
206
+ :to_jboss_web => [:jvm_route],
207
+ :to_jms => [:peer_id]
208
+ },
209
+ :defaults => {
210
+ :multicast_ip => "239.255.0.1",
211
+ :partition_name => "#{@profile}-partition",
212
+ :jvm_route => "#{@profile}"
213
+ }
214
+
215
+ register :jms,
216
+
217
+ :priority => @@pre_install,
218
+ :move_config => {
219
+ :to_run_conf => [:peer_id]
220
+ }
221
+
222
+ register :bind,
223
+
224
+ :priority => @@pre_install,
225
+ :send_config => {
226
+ :to_init_script => {
227
+ :address => :bind_address
228
+ }
229
+ },
230
+ :move_config => {
231
+ :to_run_conf => {
232
+ :ports => :service_binding
233
+ }
234
+ },
235
+ :defaults => {
236
+ :address => 'localhost'
237
+ }
238
+
239
+ register :profile_folder,
240
+ :type => JBoss::ProfileFolder,
241
+ :priority => @@install
242
+
243
+ register :deploy_folder,
244
+
245
+ :type => JBoss::DeployFolder,
246
+ :priority => @@post_install,
247
+ :multiple_instances => true
248
+
249
+
250
+ register :resource,
251
+
252
+ :type => JBoss::Resource,
253
+ :priority => @@pre_setup,
254
+ :multiple_instances => true
255
+
256
+ register :jmx,
257
+
258
+ :type => JBoss::JMX,
259
+ :priority => @@setup,
260
+ :send_config => {
261
+ :to_init_script => {
262
+ :password => :jmx_password,
263
+ :user => :jmx_user
264
+ }
265
+ }
266
+
267
+ register :datasource,
268
+
269
+ :type => JBoss::Datasource,
270
+ :priority => @@setup,
271
+ :multiple_instances => true
272
+
273
+ register :xa_datasource,
274
+
275
+ :type => JBoss::XADatasource,
276
+ :priority => @@setup,
277
+ :multiple_instances => true
278
+
279
+ register :default_ds,
280
+
281
+ :type => JBoss::HypersonicReplacer,
282
+ :priority => @@setup
283
+
284
+ register :mod_cluster,
285
+
286
+ :type => JBoss::ModCluster,
287
+ :priority => @@setup,
288
+ :move_config => {
289
+ :to_run_conf => [
290
+ :advertise,
291
+ :advertise_group_address,
292
+ :advertise_port,
293
+ :proxy_list,
294
+ :excluded_contexts,
295
+ :auto_enable_contexts
296
+ ]
297
+ },
298
+ :defaults => {
299
+ :path => "#{@base_dir}/resources/mod_cluster.sar",
300
+ }
301
+
302
+ register :jboss_web,
303
+
304
+ :type => JBoss::Web,
305
+ :priority => @@setup
306
+
307
+ register :run_conf,
308
+
309
+ :type => JBoss::RunConf,
310
+ :priority => @@post_setup,
311
+ :send_config => {
312
+ :to_init_script => [:service_binding]
313
+ },
314
+ :defaults => {
315
+ :template_path => "#{@base_dir}/resources/run.conf.erb",
316
+
317
+ :stack_size => '128k',
318
+ :heap_size => '2048m',
319
+ :perm_size => '256m'
320
+ }
321
+
322
+ register :slimming,
323
+
324
+ :type => JBoss::Slimming,
325
+ :priority => @@post_setup
326
+
327
+ register :init_script,
328
+
329
+ :type => JBoss::ServiceScript,
330
+ :priority => @@final,
331
+ :defaults => {
332
+ :path => "#{@base_dir}/resources/jboss_init_redhat.sh.erb",
333
+ :jmx_user => "admin",
334
+ :jmx_password => "admin",
335
+ :bind_address => "0.0.0.0",
336
+ :java_path => "/usr/java/default",
337
+ :jnp_port => 1099,
338
+ :jboss_user => "RUNASIS"
339
+ }
340
+ end
341
+
342
+ end
343
+
344
+ end