Class: Jolokia::Client
- Inherits:
-
Object
- Object
- Jolokia::Client
- Defined in:
- lib/jolokia/client.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #execute(mbean, operation, args = nil) ⇒ Object
- #get_attribute(mbean, attribute, path = nil) ⇒ Object
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #request(method, opts) ⇒ Object
- #set_attribute(mbean, attribute, value, path = nil) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 |
# File 'lib/jolokia/client.rb', line 8 def initialize(opts = {}) @url = opts[:url] end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/jolokia/client.rb', line 6 def url @url end |
Instance Method Details
#execute(mbean, operation, args = nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/jolokia/client.rb', line 31 def execute(mbean, operation, args = nil) = { 'type' => 'exec', 'mbean' => mbean, 'operation' => operation } if args ['arguments'] = args.is_a?(Array) ? args : [args] end request(:post, ) end |
#get_attribute(mbean, attribute, path = nil) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/jolokia/client.rb', line 12 def get_attribute(mbean, attribute, path = nil) = { 'type' => 'read', 'mbean' => mbean, 'attribute' => attribute } ['path'] = path if path request(:post, )['value'] end |
#request(method, opts) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/jolokia/client.rb', line 45 def request(method, opts) resp = connection.send(method, '', opts) if resp.body['status'] != 200 raise RemoteError.new(resp.body['status'], resp.body['error'], resp.body['stacktrace']) end resp.body end |
#set_attribute(mbean, attribute, value, path = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jolokia/client.rb', line 19 def set_attribute(mbean, attribute, value, path = nil) = { 'type' => 'write', 'mbean' => mbean, 'attribute' => attribute, 'value' => value } ['path'] = path if path request(:post, ) end |