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,104 @@
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 "component"
24
+
25
+ require "rexml/document"
26
+
27
+ include REXML
28
+
29
+ module JBoss
30
+
31
+ # A class to add deploy folders to a JBoss Profile.
32
+ #
33
+ #
34
+ # Note: there is a bug in JBoss (https://issues.jboss.org/browse/JBAS-9387) that affect
35
+ # this class if profile.xml needs to be changed (deploy folder outside
36
+ # $JBOSS_HOME/server/$PROFILE/deploy)
37
+ #
38
+ # author: Marcelo Guimarães <ataxexe@gmail.com>
39
+ class DeployFolder
40
+ include Component, FileUtils
41
+
42
+ def configure folder
43
+ @folder = folder.to_s
44
+
45
+ @absolute_path = @folder.start_with? '/'
46
+ @outside_deploy = (!@folder.start_with?('deploy') and not @absolute_path)
47
+
48
+ @configure_vsf_and_profile = (@absolute_path or @outside_deploy)
49
+
50
+ @path = @absolute_path ? @folder : "#{@jboss.profile}/#{@folder}"
51
+
52
+ @folder = "${jboss.server.home.url}#{@folder}" if @outside_deploy
53
+ @folder = "file://#{@folder}" if @absolute_path
54
+ end
55
+
56
+ def process
57
+ @logger.info "Creating deploy folder: #{@path}"
58
+ mkdir_p @path
59
+
60
+ if @configure_vsf_and_profile
61
+ @logger.warn "Please change your profile.xml file according to this issue <https://issues.jboss.org/browse/JBAS-9387>"
62
+ configure_vfs
63
+ configure_profile
64
+ end
65
+ end
66
+
67
+ def configure_profile
68
+ @logger.info "Updating profile.xml"
69
+ processor = new_file_processor
70
+ processor.with "#{@jboss.profile}/conf/bootstrap/profile.xml", :xml do |action|
71
+ action.to_process do |xml, jboss|
72
+ element = XPath.first xml, "//property[@name='applicationURIs']"
73
+ element = XPath.first element, "//list[@elementClass='java.net.URI']"
74
+ deploy = Element::new "value"
75
+ deploy.text = @folder
76
+ element << deploy
77
+ xml
78
+ end
79
+ end
80
+ processor.process
81
+ end
82
+
83
+ def configure_vfs
84
+ @logger.info "Updating vfs.xml"
85
+ processor = new_file_processor
86
+ processor.with "#{@jboss.profile}/conf/bootstrap/vfs.xml", :xml do |action|
87
+ action.to_process do |xml, jboss|
88
+ map = XPath.first xml, "//map[@keyClass='java.net.URL']"
89
+ entry = Document::new <<XML
90
+ <entry>
91
+ <key>#{@folder}</key>
92
+ <value><inject bean="VfsNamesExceptionHandler"/></value>
93
+ </entry>
94
+ XML
95
+ map << entry
96
+ xml
97
+ end
98
+ end
99
+ processor.process
100
+ end
101
+
102
+ end
103
+
104
+ end
@@ -0,0 +1,58 @@
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
+ module JBoss
27
+ # A class to replace the shipped Hypersonic datasource for a JBoss profile.
28
+ #
29
+ # Configuration:
30
+ #
31
+ # The configuration can be a JBossDatasource or a Hash to configure a JBossDatasource.
32
+ #
33
+ # author: Marcelo Guimarães <ataxexe@gmail.com>
34
+ class HypersonicReplacer
35
+ include Component, FileUtils
36
+
37
+ def configure config
38
+ @datasource = config if config.is_a? Datasource
39
+ @datasource ||= Datasource::new(@jboss, @logger, config)
40
+ @datasource.jndi_name = "DefaultDS"
41
+ end
42
+
43
+ def process
44
+ @logger.info "Removing Hypersonic..."
45
+ rm_f "#{@jboss.profile}/deploy/hsqldb-ds.xml"
46
+ rm_f "#{@jboss.profile}/deploy/messaging/hsqldb-persistence-service.xml"
47
+
48
+ @datasource.process
49
+
50
+ @logger.info "Copying persistence service template for #{@datasource.type}..."
51
+ # For postgres, the jms example filename differs from jca
52
+ @datasource.type = :postgresql if @datasource.type.to_s == "postgres"
53
+ cp "#{@jboss.home}/docs/examples/jms/#{@datasource.type}-persistence-service.xml", "#{@jboss.profile}/deploy/messaging"
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -0,0 +1,117 @@
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 'component'
24
+
25
+ require "rexml/document"
26
+
27
+ include REXML
28
+
29
+ module JBoss
30
+ class Web
31
+ include Component
32
+
33
+ def defaults
34
+ {
35
+ :connectors => [],
36
+ :jvm_route => nil
37
+ }
38
+ end
39
+
40
+ def connector_defaults
41
+ {
42
+ :http => {
43
+ :address => "${jboss.bind.address}",
44
+ :protocol => "HTTP/1.1",
45
+ :port => 8080
46
+ },
47
+ :ajp => {
48
+ :address => "${jboss.bind.address}",
49
+ :protocol => "AJP/1.3",
50
+ :port => 8009,
51
+ :redirect_port => 8443
52
+ },
53
+ :https => {
54
+ :addres => "${jboss.bind.address}",
55
+ :port => 8443,
56
+ :scheme => "https",
57
+ :secure => true,
58
+ :ssl_protocol => "TLS",
59
+ :client_auth => false,
60
+ :keystore_file => '${jboss.server.home.dir}/conf/.keystore'
61
+ },
62
+ :other => {
63
+ :address => "${jboss.bind.address}",
64
+ :protocol => "HTTP/1.1"
65
+ }
66
+ }
67
+ end
68
+
69
+ def process
70
+ @processor = new_file_processor
71
+ @actions = []
72
+ configure_connectors
73
+ configure_engine if @config[:jvm_route]
74
+ @processor.with "#{@jboss.profile}/deploy/jbossweb.sar/server.xml", :xml do |action|
75
+ action.to_process do |xml, jboss|
76
+ @actions.each do |block|
77
+ xml = block.call(xml, jboss)
78
+ end
79
+ xml
80
+ end
81
+ end
82
+ @processor.process
83
+ end
84
+
85
+ def configure_connectors
86
+ @config[:connectors].each do |type, attributes|
87
+ defaults = connector_defaults[type.to_sym]
88
+ defaults ||= connector_defaults[:other]
89
+ attributes = defaults.merge attributes
90
+ configure_connector attributes, defaults
91
+ end
92
+ end
93
+
94
+ def configure_connector attributes, defaults
95
+ @actions << lambda do |xml, jboss|
96
+ tag = XPath.first xml, "//Connector[@protocol='#{defaults[:protocol]}'][@port='#{defaults[:port]}']"
97
+ unless tag
98
+ tag = Element::new "Connector"
99
+ xml.insert_after "//Connector", tag
100
+ end
101
+ attributes.each do |key, value|
102
+ key = key.to_s.camelize.uncapitalize if key.is_a? Symbol
103
+ tag.attributes[key] = value.to_s
104
+ end
105
+ xml
106
+ end
107
+ end
108
+
109
+ def configure_engine
110
+ @actions << lambda do |xml, jboss|
111
+ engine = XPath.first xml, "//Engine[@name='jboss.web']"
112
+ engine.attributes["jvmRoute"] = @config[:jvm_route]
113
+ xml
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,88 @@
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 "component"
24
+
25
+ module JBoss
26
+ # This class configures the JXM user for a JBoss profile.
27
+ #
28
+ # Configuration:
29
+ #
30
+ # :user => the jxm user (default: 'admin')
31
+ # :password => the jmx user password (default: 'admin')
32
+ # :roles => the roles mapped for the user (default: 'JBossAdmin,HttpInvoker')
33
+ #
34
+ # author: Marcelo Guimarães <ataxexe@gmail.com>
35
+ class JMX
36
+ include Component
37
+
38
+ def configure config
39
+ @config = config
40
+ @password = config[:password]
41
+ @user = config[:user]
42
+ @roles = config[:roles]
43
+ end
44
+
45
+ def defaults
46
+ {
47
+ :user => "admin",
48
+ :password => "admin",
49
+ :roles => "JBossAdmin,HttpInvoker"
50
+ }
51
+ end
52
+
53
+ def process
54
+ configure_users
55
+ configure_roles
56
+ end
57
+
58
+ def configure_users
59
+ processor = new_file_processor
60
+ processor.with "#{@jboss.profile}/conf/props/#{users_properties_file}" do |action|
61
+ action.to_process do |content, jboss|
62
+ [@user, @password].join '='
63
+ end
64
+ end
65
+ processor.process
66
+ end
67
+
68
+ def configure_roles
69
+ processor = new_file_processor
70
+ processor.with "#{@jboss.profile}/conf/props/#{roles_properties_file}" do |action|
71
+ action.to_process do |content, jboss|
72
+ [@user, @roles].join '='
73
+ end
74
+ end
75
+ processor.process
76
+ end
77
+
78
+ def users_properties_file
79
+ "jmx-console-users.properties"
80
+ end
81
+
82
+ def roles_properties_file
83
+ "jmx-console-roles.properties"
84
+ end
85
+
86
+ end
87
+
88
+ end
@@ -0,0 +1,81 @@
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 "component"
24
+ require_relative "../jboss_path"
25
+
26
+ require "logger"
27
+ require "rexml/document"
28
+
29
+ include REXML
30
+
31
+ module JBoss
32
+ # A class to install and configure a mod_cluster service in a JBoss profile
33
+ #
34
+ # Configuration:
35
+ #
36
+ # :path => where the mod_cluster.sar is located
37
+ # :folder => where the mod_cluster.sar should be installed (default: $JBOSS_HOME/server/$CONFIG/deploy)
38
+ #
39
+ # The additional configurations are the entries in the bean ModClusterConfig (mod_cluster-jboss-beans.xml)
40
+ # and can be in a String form (using the entry name) or in a Symbol form (using ruby nomenclature - :sticky_session)
41
+ #
42
+ # author: Marcelo Guimarães <ataxexe@gmail.com>
43
+ class ModCluster
44
+ include Component, FileUtils
45
+
46
+ def defaults
47
+ {:folder => "#{@jboss.profile}/deploy"}
48
+ end
49
+
50
+ def configure config
51
+ @path = config.delete :path
52
+ @folder = config.delete :folder
53
+ @config = config
54
+ end
55
+
56
+ def process
57
+ @logger.info "Installing mod_cluster.sar"
58
+ cp_r @path, @folder
59
+
60
+ return if @config.empty?
61
+
62
+ @logger.info "Configuring mod_cluster.sar"
63
+ processor = new_file_processor
64
+ processor.with "#{@folder}/mod_cluster.sar/META-INF/mod_cluster-jboss-beans.xml", :xml do |action|
65
+ action.to_process do |xml, jboss|
66
+ config = XPath.first(xml, "//bean[@name='ModClusterConfig']")
67
+ @config.each do |property, value|
68
+ element = XPath.first config, "property[@name='#{property.to_s.camelize.uncapitalize}']"
69
+ if element
70
+ @logger.debug "Configuring #{element.attribute('name').value} to \"#{value}\""
71
+ element.text = value
72
+ end
73
+ end
74
+ xml
75
+ end
76
+ end
77
+ processor.process
78
+ end
79
+
80
+ end
81
+ end